Add tax class on account categories
This commit is contained in:
parent
7d7bf4d635
commit
7f7382ab48
|
@ -2,6 +2,10 @@
|
|||
msgid ""
|
||||
msgstr "Content-Type: text/plain; charset=utf-8\n"
|
||||
|
||||
msgctxt "field:product.category,woocommerce_tax_class:"
|
||||
msgid "WooCommerce Tax Class"
|
||||
msgstr "Classe Impost WooCommerce"
|
||||
|
||||
msgctxt "field:web.shop,price_list:"
|
||||
msgid "Price List"
|
||||
msgstr "Tarifa"
|
||||
|
|
|
@ -2,6 +2,10 @@
|
|||
msgid ""
|
||||
msgstr "Content-Type: text/plain; charset=utf-8\n"
|
||||
|
||||
msgctxt "field:product.category,woocommerce_tax_class:"
|
||||
msgid "WooCommerce Tax Class"
|
||||
msgstr "Classe Impuesto WooCommerce"
|
||||
|
||||
msgctxt "field:web.shop,price_list:"
|
||||
msgid "Price List"
|
||||
msgstr "Tarifa"
|
||||
|
|
21
product.py
21
product.py
|
@ -1,6 +1,8 @@
|
|||
# The COPYRIGHT file at the top level of this repository contains the full
|
||||
# copyright notices and license terms.
|
||||
from trytond.model import fields
|
||||
from trytond.pool import PoolMeta
|
||||
from trytond.pyson import Eval
|
||||
from trytond.tools import slugify
|
||||
|
||||
from .web import ShopWooCommerceIdMixin
|
||||
|
@ -9,6 +11,12 @@ from .web import ShopWooCommerceIdMixin
|
|||
class Category(ShopWooCommerceIdMixin, metaclass=PoolMeta):
|
||||
__name__ = 'product.category'
|
||||
|
||||
woocommerce_tax_class = fields.Char("WooCommerce Tax Class",
|
||||
states={
|
||||
'invisible': ~Eval('accounting', False),
|
||||
},
|
||||
depends=['accounting'])
|
||||
|
||||
def get_woocommerce_entity(self):
|
||||
values = {
|
||||
'name': self.name,
|
||||
|
@ -26,6 +34,16 @@ class Category(ShopWooCommerceIdMixin, metaclass=PoolMeta):
|
|||
class Product(ShopWooCommerceIdMixin, metaclass=PoolMeta):
|
||||
__name__ = 'product.product'
|
||||
|
||||
@property
|
||||
def woocommerce_tax_class(self):
|
||||
if self.account_category:
|
||||
parent = self.account_category
|
||||
while parent:
|
||||
if parent.woocommerce_tax_class:
|
||||
return parent.woocommerce_tax_class
|
||||
parent = parent.parent
|
||||
return ''
|
||||
|
||||
def get_woocommerce_entity(self):
|
||||
short_description = description = (self.description or '')
|
||||
lines = description.splitlines()
|
||||
|
@ -56,4 +74,7 @@ class Product(ShopWooCommerceIdMixin, metaclass=PoolMeta):
|
|||
if category.woocommerce_id:
|
||||
categories.append({'id': category.woocommerce_id})
|
||||
values['categories'] = categories
|
||||
tax_class = self.woocommerce_tax_class
|
||||
if tax_class is not None:
|
||||
values['tax_class'] = tax_class
|
||||
return values
|
||||
|
|
|
@ -0,0 +1,12 @@
|
|||
<?xml version="1.0"?>
|
||||
<!-- The COPYRIGHT file at the top level of this repository contains the full
|
||||
copyright notices and license terms. -->
|
||||
<tryton>
|
||||
<data>
|
||||
<record model="ir.ui.view" id="category_view_form">
|
||||
<field name="model">product.category</field>
|
||||
<field name="inherit" ref="product.category_view_form"/>
|
||||
<field name="name">category_form</field>
|
||||
</record>
|
||||
</data>
|
||||
</tryton>
|
|
@ -2,10 +2,12 @@
|
|||
version=5.6.0
|
||||
depends:
|
||||
ir
|
||||
account_product
|
||||
product
|
||||
product_price_list
|
||||
sale
|
||||
web_shop
|
||||
xml:
|
||||
message.xml
|
||||
product.xml
|
||||
web.xml
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
<?xml version="1.0"?>
|
||||
<!-- The COPYRIGHT file at the top level of this repository contains the full
|
||||
copyright notices and license terms. -->
|
||||
<data>
|
||||
<xpath expr="/form/notebook/page[@id='accounting']/field[@name='taxes_parent']" position="after">
|
||||
<label name="woocommerce_tax_class"/>
|
||||
<field name="woocommerce_tax_class"/>
|
||||
</xpath>
|
||||
</data>
|
Loading…
Reference in New Issue