changeset 117f556e4c23 in modules/customs:default
details: https://hg.tryton.org/modules/customs?cmd=changeset&node=117f556e4c23
description:
Add country of origin
issue10669
review362271002
diffstat:
CHANGELOG | 2 ++
product.py | 36 ++++++++++++++++++++++++++++++------
view/template_form.xml | 4 +++-
3 files changed, 35 insertions(+), 7 deletions(-)
diffs (95 lines):
diff -r d2f6c841e74e -r 117f556e4c23 CHANGELOG
--- a/CHANGELOG Sun Jul 04 17:54:47 2021 +0200
+++ b/CHANGELOG Tue Oct 12 10:08:42 2021 +0200
@@ -1,3 +1,5 @@
+* Add country of origin
+
Version 6.0.0 - 2021-05-03
* Bug fixes (see mercurial logs for details)
diff -r d2f6c841e74e -r 117f556e4c23 product.py
--- a/product.py Sun Jul 04 17:54:47 2021 +0200
+++ b/product.py Tue Oct 12 10:08:42 2021 +0200
@@ -55,13 +55,19 @@
return self.parent.customs
return self.customs
- def get_tariff_code(self, pattern):
+ def get_tariff_codes(self, pattern):
if not self.tariff_codes_parent:
for link in self.tariff_codes:
if link.tariff_code.match(pattern):
- return link.tariff_code
+ yield link.tariff_code
else:
- return self.parent.get_tariff_code(pattern)
+ yield from self.parent.get_tariff_codes(pattern)
+
+ def get_tariff_code(self, pattern):
+ try:
+ return next(self.get_tariff_codes(pattern))
+ except StopIteration:
+ pass
@classmethod
def view_attributes(cls):
@@ -105,6 +111,12 @@
| Eval('tariff_codes_category', False)),
},
depends=['type', 'tariff_codes_category'])
+ country_of_origin = fields.Many2One(
+ 'country.country', "Country",
+ states={
+ 'invisible': Eval('type') == 'service',
+ },
+ depends=['type'])
@classmethod
def __register__(cls, module_name):
@@ -131,13 +143,19 @@
def default_tariff_codes_category(cls):
return False
- def get_tariff_code(self, pattern):
+ def get_tariff_codes(self, pattern):
if not self.tariff_codes_category:
for link in self.tariff_codes:
if link.tariff_code.match(pattern):
- return link.tariff_code
+ yield link.tariff_code
else:
- return self.customs_category.get_tariff_code(pattern)
+ yield from self.customs_category.get_tariff_codes(pattern)
+
+ def get_tariff_code(self, pattern):
+ try:
+ return next(self.get_tariff_codes(pattern))
+ except StopIteration:
+ pass
@classmethod
def view_attributes(cls):
@@ -182,3 +200,9 @@
class Product(metaclass=PoolMeta):
__name__ = 'product.product'
+
+ def get_tariff_codes(self, pattern):
+ yield from self.template.get_tariff_codes(pattern)
+
+ def get_tariff_code(self, pattern):
+ return self.template.get_tariff_code(pattern)
diff -r d2f6c841e74e -r 117f556e4c23 view/template_form.xml
--- a/view/template_form.xml Sun Jul 04 17:54:47 2021 +0200
+++ b/view/template_form.xml Tue Oct 12 10:08:42 2021 +0200
@@ -6,7 +6,9 @@
<page string="Customs" id="customs">
<label name="customs_category"/>
<field name="customs_category"/>
- <newline/>
+ <label name="country_of_origin"/>
+ <field name="country_of_origin"/>
+
<label name="tariff_codes_category"/>
<field name="tariff_codes_category"/>
<field name="tariff_codes" colspan="4"