[IMP] intrastat_product_type: improve support for is accessory cost
This commit is contained in:
@@ -39,3 +39,23 @@ class ProductTemplate(models.Model):
|
||||
"On product '%s' which is not a consumable, "
|
||||
"Intrastat Type must have the same value as Type.")
|
||||
% pt.display_name)
|
||||
|
||||
# inherit method from intrastat_base
|
||||
@api.constrains("intrastat_type", "is_accessory_cost")
|
||||
def _check_accessory_cost(self):
|
||||
for this in self:
|
||||
if this.is_accessory_cost and this.intrastat_type != "service":
|
||||
raise ValidationError(
|
||||
_(
|
||||
"The option 'Is accessory cost?' should only be "
|
||||
"activated on 'Service' products. You have activated "
|
||||
"this option for the product '%(product_name)s' which is "
|
||||
"configured with type '%(product_type)s'."
|
||||
)
|
||||
% {
|
||||
"product_name": this.display_name,
|
||||
"product_type": this._fields["type"].convert_to_export(
|
||||
this.type, this
|
||||
),
|
||||
}
|
||||
)
|
||||
|
||||
@@ -11,11 +11,15 @@
|
||||
<record id="product_template_form_view" model="ir.ui.view">
|
||||
<field name="name">intrastat_product_type.product.template.form</field>
|
||||
<field name="model">product.template</field>
|
||||
<field name="inherit_id" ref="product.product_template_form_view" />
|
||||
<field name="inherit_id" ref="intrastat_base.product_template_form_view" />
|
||||
<field name="priority">150</field>
|
||||
<field name="arch" type="xml">
|
||||
<field name="detailed_type" position="after">
|
||||
<field name="intrastat_type" attrs="{'invisible': [('type', '!=', 'consu')]}"/>
|
||||
</field>
|
||||
<field name="is_accessory_cost" position="attributes">
|
||||
<attribute name="attrs">{'invisible': [('intrastat_type', '!=', 'service')]}</attribute>
|
||||
</field>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user