Commit f907ad19 authored by Maxime Richez's avatar Maxime Richez
Browse files

Add more details in tariff code list on product form

Closes #11888
parent d5a5f27fad76
Pipeline #61489 passed with stages
in 16 minutes and 59 seconds
* Show tariff code criteria on product form
* Support country organization for tariff code and duty rate
* Use ir.calendar.month for tariff code months
......
......@@ -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
......
......@@ -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>
......@@ -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>
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment