changeset bf8cd50e1840 in modules/account_product:default
details: 
https://hg.tryton.org/modules/account_product?cmd=changeset&node=bf8cd50e1840
description:
        Add deductible rate of taxes to supplier invoice

        issue6911
        review341801002
diffstat:

 CHANGELOG              |   2 ++
 product.py             |  28 ++++++++++++++++++++++++++++
 view/category_form.xml |   4 +++-
 3 files changed, 33 insertions(+), 1 deletions(-)

diffs (89 lines):

diff -r 28eda48cb3a4 -r bf8cd50e1840 CHANGELOG
--- a/CHANGELOG Sat Apr 10 23:46:23 2021 +0200
+++ b/CHANGELOG Sun Apr 11 18:11:05 2021 +0200
@@ -1,3 +1,5 @@
+* Add deductible rate for supplier taxes
+
 Version 5.8.0 - 2020-11-02
 * Bug fixes (see mercurial logs for details)
 * Remove support for Python 3.5
diff -r 28eda48cb3a4 -r bf8cd50e1840 product.py
--- a/product.py        Sat Apr 10 23:46:23 2021 +0200
+++ b/product.py        Sun Apr 11 18:11:05 2021 +0200
@@ -126,6 +126,17 @@
             },
         depends=['taxes_parent', 'accounting'],
         help="The taxes to apply when purchasing products of this category.")
+    supplier_taxes_deductible_rate = fields.Numeric(
+        "Supplier Taxes Deductible Rate", digits=(14, 10),
+        domain=[
+            ('supplier_taxes_deductible_rate', '>=', 0),
+            ('supplier_taxes_deductible_rate', '<=', 1),
+            ],
+        states={
+            'invisible': (
+                Eval('taxes_parent') | ~Eval('accounting', False)),
+            },
+        depends=['taxes_parent', 'accounting'])
     customer_taxes_used = fields.Function(fields.Many2Many(
             'account.tax', None, None, "Customer Taxes Used"), 'get_taxes')
     supplier_taxes_used = fields.Function(fields.Many2Many(
@@ -172,6 +183,10 @@
             'default_category_account_revenue', **pattern)
         return account.id if account else None
 
+    @classmethod
+    def default_supplier_taxes_deductible_rate(cls):
+        return 1
+
     def get_account(self, name, **pattern):
         if self.account_parent:
             return self.parent.get_account(name, **pattern)
@@ -235,6 +250,13 @@
     def account_revenue_used(self):
         pass
 
+    @property
+    def supplier_taxes_deductible_rate_used(self):
+        if self.taxes_parent:
+            return self.parent.supplier_taxes_deductible_rate_used
+        else:
+            return self.supplier_taxes_deductible_rate
+
 
 class CategoryAccount(ModelSQL, CompanyValueMixin):
     "Category Account"
@@ -368,6 +390,10 @@
                         name=self.rec_name))
         return taxes
 
+    @property
+    def supplier_taxes_deductible_rate_used(self):
+        return self.get_taxes('supplier_taxes_deductible_rate_used')
+
 
 class Product(metaclass=PoolMeta):
     __name__ = 'product.product'
@@ -375,6 +401,8 @@
     account_revenue_used = template_property('account_revenue_used')
     customer_taxes_used = template_property('customer_taxes_used')
     supplier_taxes_used = template_property('supplier_taxes_used')
+    supplier_taxes_deductible_rate_used = template_property(
+        'supplier_taxes_deductible_rate_used')
 
 
 class TemplateAccountCategory(ModelSQL):
diff -r 28eda48cb3a4 -r bf8cd50e1840 view/category_form.xml
--- a/view/category_form.xml    Sat Apr 10 23:46:23 2021 +0200
+++ b/view/category_form.xml    Sun Apr 11 18:11:05 2021 +0200
@@ -21,7 +21,9 @@
             <separator string="Taxes" id="taxes" colspan="4"/>
             <label name="taxes_parent"/>
             <field name="taxes_parent"/>
-            <newline/>
+            <label name="supplier_taxes_deductible_rate"/>
+            <field name="supplier_taxes_deductible_rate"/>
+
             <field name="customer_taxes" colspan="2"/>
             <field name="supplier_taxes" colspan="2"/>
         </page>

Reply via email to