[FIX] product,*: fix purchase page visibility in product form view

Before this commit, when purchase app (or account) is installed,
the `purchase` page in product form view is always visible even
if the product displayed in the form view cannot be purchased.
The reason is when `attrs` has been removed and replaced by python
condition inside `readonly`, `required` and `invisible` attributes,
since the purchase page had `attrs="{'invisible': ...}"` and
`invisible="1"` defined in its attributes, the condition in `attrs`
has completely removed when the `attrs` has been deleted.

This commit fixes the issue by updating the initial invisible defined
in product module to have `invisible="1 or not purchase_ok"` to keep
the condition that was initially defined in `attrs`.
In purchase and account module, instead of replacing `invisible="1"`
by `invisible="0"`, we will just remove `1 or` to show the purchase
page only if `not purchase_ok` as it was the case before.

task-3506730

Part-of: odoo/odoo#135840
This commit is contained in:
Xavier Bol (xbo)
2023-10-19 14:47:20 +00:00
parent 5624809daf
commit fed423910b
4 changed files with 4 additions and 4 deletions
+1 -1
View File
@@ -50,7 +50,7 @@
<field name="inherit_id" ref="product.product_template_form_view"/>
<field name="arch" type="xml">
<xpath expr="//page[@name='purchase']" position="attributes">
<attribute name="invisible">0</attribute>
<attribute name="invisible" remove="1" separator=" or "></attribute>
</xpath>
<xpath expr="//field[@name='company_id']" position="after">
<field name="fiscal_country_codes" invisible="1"/>
+1 -1
View File
@@ -87,7 +87,7 @@
</page>
</xpath>
<xpath expr="//page[@name='purchase']" position="attributes">
<attribute name="invisible">detailed_type == "combo"</attribute>
<attribute name="invisible" separator=" or " add="detailed_type == 'combo'"></attribute>
</xpath>
<xpath expr="//page[@name='inventory']" position="attributes">
<attribute name="invisible">type in ['combo', 'service']</attribute>
+1 -1
View File
@@ -111,7 +111,7 @@
</group>
</group>
</page>
<page string="Purchase" name="purchase" invisible="1">
<page string="Purchase" name="purchase" invisible="1 or not purchase_ok">
<group name="purchase">
<group string="Vendor Bills" name="bill"/>
</group>
+1 -1
View File
@@ -38,7 +38,7 @@
<field name="inherit_id" ref="product.product_template_form_view"/>
<field name="arch" type="xml">
<xpath expr="//page[@name='purchase']" position="attributes">
<attribute name="invisible">0</attribute>
<attribute name="invisible" remove="1" separator=" or "></attribute>
<attribute name="groups">purchase.group_purchase_user</attribute>
</xpath>
<group name="purchase" position="before">