Skip to content

Commit

Permalink
[FIX] product,sale,point_of_sale: fix sales page visibility
Browse files Browse the repository at this point in the history
Before this commit, the `Sales` page is always visible in product
form view when `point_of_sale` and/or `sale` modules are installed
even if the product cannot be sold.
The reason is because the initial condition contained in
`attrs="{'invisible': ...}"` for that page has been completely removed
since the recent changes to remove `attrs` attribute and allow having
python condition inside `invisible`, `readonly` and `required` attributes
(instead of having only True or False as value for those attributes).

This commit reviews the visibility condition for that page to completely
hide that page in product module as it is currently the case but it also
adds the condition we had in attrs. That is, in product module, the
invisible attribute for that page will be equal to `1 or not sale_ok`
(and so always invisible thanks to `1 or ...`) and when `sales` or
`point_of_sale` modules will be installed then `1 or ` will be removed
to just keep `not sale_ok` inside `invisible` attribute.

task-3506730

closes odoo#135840

Signed-off-by: Xavier Bol (xbo) <[email protected]>
  • Loading branch information
xavierbol committed Oct 19, 2023
1 parent fed4239 commit adb0476
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion addons/point_of_sale/views/product_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
<field name="inherit_id" ref="product.product_template_form_view"/>
<field name="arch" type="xml">
<xpath expr="//page[@name='sales']" position="attributes">
<attribute name="invisible">0</attribute>
<attribute name="invisible" remove="1" separator=" or "></attribute>
</xpath>
<xpath expr="//page[@name='sales']/group[@name='sale']" position="inside">
<group name="pos" string="Point of Sale" invisible="not sale_ok">
Expand Down
2 changes: 1 addition & 1 deletion addons/product/views/product_views.xml
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@
<field colspan="2" name="description" nolabel="1" placeholder="This note is only for internal purposes."/>
</group>
</page>
<page string="Sales" name="sales" invisible="1">
<page string="Sales" name="sales" invisible="1 or not sale_ok">
<group name="sale">
<group string="Upsell &amp; Cross-Sell" name="upsell" invisible="1"/>
</group>
Expand Down
2 changes: 1 addition & 1 deletion addons/sale/views/product_views.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<field name="inherit_id" ref="product.product_template_form_view"/>
<field name="arch" type="xml">
<page name="sales" position="attributes">
<attribute name="invisible">0</attribute>
<attribute name="invisible" remove="1" separator=" or "></attribute>
</page>
<field name="product_variant_count" position="after">
<field name="service_type" widget="radio" invisible="True"/>
Expand Down

0 comments on commit adb0476

Please sign in to comment.