Cédric Krier pushed to branch branch/default at Tryton / Tryton


Commits:
f907ad19 by Maxime Richez at 2023-01-11T14:32:09+01:00
Add more details in tariff code list on product form

Closes #11888
- - - - -


4 changed files:

- modules/customs/CHANGELOG
- modules/customs/product.py
- modules/customs/view/product-tariff_code_list.xml
- modules/customs/view/product-tariff_code_list_sequence.xml


Changes:

=====================================
modules/customs/CHANGELOG
=====================================
@@ -1,3 +1,4 @@
+* Show tariff code criteria on product form
 * Support country organization for tariff code and duty rate
 * Use ir.calendar.month for tariff code months
 


=====================================
modules/customs/product.py
=====================================
@@ -182,6 +182,30 @@
             ], required=True)
     tariff_code = fields.Many2One('customs.tariff.code', 'Tariff Code',
         required=True, ondelete='CASCADE')
+    country = fields.Function(
+        fields.Many2One('country.country', "Country"), 'get_tariff_code_field')
+    organization = fields.Function(
+        fields.Many2One('country.organization', "Organization"),
+        'get_tariff_code_field')
+    start_day = fields.Function(
+        fields.Integer("Start Day"), 'get_tariff_code_field')
+    start_month = fields.Function(
+        fields.Many2One('ir.calendar.month', "Start Month"),
+        'get_tariff_code_field')
+    end_day = fields.Function(
+        fields.Integer("End Day"), 'get_tariff_code_field')
+    end_month = fields.Function(
+        fields.Many2One('ir.calendar.month', "End Month"),
+        'get_tariff_code_field')
+
+    def get_tariff_code_field(self, name):
+        field = getattr(self.__class__, name)
+        value = getattr(self.tariff_code, name, None)
+        if isinstance(value, ModelSQL):
+            if field._type == 'reference':
+                return str(value)
+            return value.id
+        return value
 
     def get_rec_name(self, name):
         return self.tariff_code.rec_name


=====================================
modules/customs/view/product-tariff_code_list.xml
=====================================
@@ -4,4 +4,10 @@
 <tree>
     <field name="product" expand="2"/>
     <field name="tariff_code" expand="1"/>
+    <field name="organization" optional="0"/>
+    <field name="country" optional="0"/>
+    <field name="start_day" optional="1"/>
+    <field name="start_month" optional="1"/>
+    <field name="end_day" optional="1"/>
+    <field name="end_month" optional="1"/>
 </tree>


=====================================
modules/customs/view/product-tariff_code_list_sequence.xml
=====================================
@@ -4,4 +4,10 @@
 <tree sequence="sequence">
     <field name="product" expand="2"/>
     <field name="tariff_code" expand="1"/>
+    <field name="organization" optional="0"/>
+    <field name="country" optional="0"/>
+    <field name="start_day" optional="1"/>
+    <field name="start_month" optional="1"/>
+    <field name="end_day" optional="1"/>
+    <field name="end_month" optional="1"/>
 </tree>



View it on Heptapod: 
https://foss.heptapod.net/tryton/tryton/-/commit/f907ad19330744e802f75af27109720d36961ea3

-- 
View it on Heptapod: 
https://foss.heptapod.net/tryton/tryton/-/commit/f907ad19330744e802f75af27109720d36961ea3
You're receiving this email because of your account on foss.heptapod.net.


Reply via email to