[IMP] product, sale: define product exclusions with their products

Following recent changes in stable deleting/archiving product variants forbidden by
attributes exclusions, installing some modules after the sale app failed because
the product `product_product_4d` specified in `product` was deleted by the attributes
exclusions of the `sale` module.

This has been fixed in stable by removing all references to this xml_id.

Nevertheless, this bug showed us that the definition of attributes exclusion
for a product in another module than the one creating it is a bad idea, as it
modifies what's allowed or not with that product, leading to potential database inconsistencies.

This commit moves the exclusions targeting products from the `product`
module to the `product` module, to reduce the risks of other modules using/referencing
the deleted/modified products in a way conflicting with the exclusions.

opw-3040916

closes odoo/odoo#104020

Signed-off-by: Victor Feyens (vfe) <vfe@odoo.com>
This commit is contained in:
Victor Piryns (pivi)
2022-11-04 17:56:43 +01:00
parent abb708f7de
commit 282945a5a5
2 changed files with 29 additions and 32 deletions
+29
View File
@@ -395,6 +395,35 @@
<field name="price_extra">6.40</field>
</record>
<record id="product_template_attribute_exclusion_1" model="product.template.attribute.exclusion">
<field name="product_tmpl_id" ref="product.product_product_4_product_template" />
<field name="value_ids" eval="[(6, 0, [ref('product.product_4_attribute_2_value_2')])]"/>
</record>
<record id="product_template_attribute_exclusion_2" model="product.template.attribute.exclusion">
<field name="product_tmpl_id" ref="product.product_product_11_product_template" />
<field name="value_ids" eval="[(6, 0, [ref('product.product_11_attribute_1_value_1')])]"/>
</record>
<record id="product_template_attribute_exclusion_3" model="product.template.attribute.exclusion">
<field name="product_tmpl_id" ref="product.product_product_11_product_template" />
<field name="value_ids" eval="[(6, 0, [ref('product.product_11_attribute_1_value_2')])]"/>
</record>
<!--
The "Customizable Desk's Aluminium" attribute value will excude:
- The "Customizable Desk's Black" attribute
- The "Office Chair's Steel" attribute
-->
<record id="product_4_attribute_1_value_2" model="product.template.attribute.value">
<field name="exclude_for" eval="[(6, 0, [ref('product.product_template_attribute_exclusion_1'), ref('product.product_template_attribute_exclusion_2')])]" />
</record>
<!--
The "Customizable Desk's Steel" attribute value will excude:
- The "Office Chair's Aluminium" attribute
-->
<record id="product_4_attribute_1_value_1" model="product.template.attribute.value">
<field name="exclude_for" eval="[(6, 0, [ref('product.product_template_attribute_exclusion_3')])]" />
</record>
<!-- MRP Demo Data-->
<record id="product_product_12" model="product.product">
-32
View File
@@ -184,38 +184,6 @@
<field name="weight">0.01</field>
</record>
<record id="product_template_attribute_exclusion_1" model="product.template.attribute.exclusion">
<field name="product_tmpl_id" ref="product.product_product_4_product_template" />
<field name="value_ids" eval="[(6,0,[ref('product.product_4_attribute_2_value_2')])]"/>
</record>
<record id="product_template_attribute_exclusion_2" model="product.template.attribute.exclusion">
<field name="product_tmpl_id" ref="product.product_product_11_product_template" />
<field name="value_ids" eval="[(6,0,[ref('product.product_11_attribute_1_value_1')])]"/>
</record>
<!--
The "Customizable Desk's Aluminium" attribute value will excude:
- The "Customizable Desk's Black" attribute
- The "Office Chair's Steel" attribute
-->
<record id="product.product_4_attribute_1_value_2" model="product.template.attribute.value">
<field name="exclude_for" eval="[(6,0,[ref('sale.product_template_attribute_exclusion_1') ,ref('sale.product_template_attribute_exclusion_2')])]" />
</record>
<record id="product_template_attribute_exclusion_3" model="product.template.attribute.exclusion">
<field name="product_tmpl_id" ref="product.product_product_11_product_template" />
<field name="value_ids" eval="[(6,0,[ref('product.product_11_attribute_1_value_2')])]"/>
</record>
<!--
The "Customizable Desk's Steel" attribute value will excude:
- The "Office Chair's Aluminium" attribute
-->
<record id="product.product_4_attribute_1_value_1" model="product.template.attribute.value">
<field name="exclude_for" eval="[(6,0,[ref('sale.product_template_attribute_exclusion_3')])]" />
</record>
<record id="advance_product_0" model="product.product">
<field name="name">Deposit</field>
<field name="categ_id" ref="product.product_category_3"/>