[IMP] product_category_tax

* add a boleean to exclude specific products to be updated
This commit is contained in:
AaronHForgeFlow
2020-11-18 18:05:58 +01:00
parent 11e7b0b993
commit 822697085c
9 changed files with 58 additions and 14 deletions

View File

@@ -40,10 +40,6 @@ In case all the products within the category will use the same tax setup:
#. Select the taxes in the product category form
#. Click on "Apply to Products"
In case a specific product need a different tax configuration you have to
either to include it in a subcategory or adjust its taxes after applying those
to the others
Bug Tracker
===========

View File

@@ -9,5 +9,5 @@
"author": "ForgeFlow S.L., Odoo Community Association (OCA)",
"website": "https://github.com/OCA/account-financial-tools",
"depends": ["account"],
"data": ["views/product_category.xml"],
"data": ["views/product_category.xml", "views/product_template.xml"],
}

View File

@@ -32,5 +32,7 @@ class ProductCategory(models.Model):
)
def update_product_taxes(self):
for template in self.product_template_ids:
for template in self.product_template_ids.filtered(
lambda p: p.taxes_updeatable_from_category
):
template.set_tax_from_category()

View File

@@ -1,12 +1,14 @@
# Copyright 2020 ForgeFlow S.L. (https://www.forgeflow.com)
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html).
from odoo import api, models
from odoo import api, fields, models
class ProductTemplate(models.Model):
_inherit = "product.template"
taxes_updeatable_from_category = fields.Boolean(default=True)
@api.onchange("categ_id")
def onchange_categ_id(self):
if self.categ_id:

View File

@@ -0,0 +1,3 @@
In case a specific product need a different tax configuration you have to
check the option "Taxes Updeatable From Category" in the Accounting tab in the
product form.

View File

@@ -2,7 +2,3 @@ In case all the products within the category will use the same tax setup:
#. Select the taxes in the product category form
#. Click on "Apply to Products"
In case a specific product need a different tax configuration you have to
either to include it in a subcategory or adjust its taxes after applying those
to the others

View File

@@ -389,9 +389,6 @@ ul.auto-toc {
<li>Select the taxes in the product category form</li>
<li>Click on “Apply to Products”</li>
</ol>
<p>In case a specific product need a different tax configuration you have to
either to include it in a subcategory or adjust its taxes after applying those
to the others</p>
</div>
<div class="section" id="bug-tracker">
<h1><a class="toc-backref" href="#id2">Bug Tracker</a></h1>

View File

@@ -76,3 +76,35 @@ class ProductCategoryTax(common.SavepointCase):
self.product_test.categ_id = test_categ.id
test_categ.update_product_taxes()
self.assertEquals(self.product_test.supplier_taxes_id, self.tax_purchase)
def test_03_taxes_not_updeatable(self):
""" Avoid update specific products"""
self.product_test3 = self.product_obj.create(
{
"name": "TEST 03",
"default_code": "TESTcode3",
"list_price": 155.0,
"supplier_taxes_id": [(6, 0, self.tax_purchase2.ids)],
}
)
self.product_test4 = self.product_obj.create(
{
"name": "TEST 04",
"default_code": "TESTcode3",
"list_price": 155.0,
"taxes_updeatable_from_category": False,
"supplier_taxes_id": [(6, 0, self.tax_purchase2.ids)],
}
)
test_categ = self.categ_obj.create(
{
"name": "Super Category",
"taxes_id": [(6, 0, self.tax_sale.ids)],
"supplier_taxes_id": [(6, 0, self.tax_purchase.ids)],
}
)
self.product_test3.categ_id = test_categ.id
self.product_test4.categ_id = test_categ.id
test_categ.update_product_taxes()
self.assertEquals(self.product_test3.supplier_taxes_id, self.tax_purchase)
self.assertNotEquals(self.product_test4.supplier_taxes_id, self.tax_purchase)

View File

@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo>
<record id="product_template_form_view_tax_updeatable" model="ir.ui.view">
<field name="name">product.template.form.tax.updeatable</field>
<field name="model">product.template</field>
<field name="inherit_id" ref="account.product_template_form_view" />
<field name="arch" type="xml">
<xpath
expr="//page[@name='invoicing']//group[@name='accounting']"
position="inside"
>
<field name="taxes_updeatable_from_category" />
</xpath>
</field>
</record>
</odoo>