[FIX] product_sale_price_from_pricelist: Fix view syntax for Odoo 18

- Replace attrs syntax with new invisible attribute format
- Fix settings view inheritance to use sale.res_config_settings_view_form
- Add configuration setting in Sales > Pricing section
- Place automatic price pricelist setting after standard pricelist config
This commit is contained in:
snt 2026-02-11 17:26:14 +01:00
parent fe137dc265
commit ec9f5a572c

View file

@ -1,4 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<?xml version="1.0" encoding="UTF-8" ?>
<odoo>
<data>
@ -9,12 +9,19 @@
<field name="inherit_id" ref="product.product_template_form_view" />
<field name="arch" type="xml">
<field name="standard_price" position="attributes">
<attribute name="readonly">last_purchase_price_compute_type != 'manual_update'</attribute>
<attribute
name="readonly"
>last_purchase_price_compute_type != 'manual_update'</attribute>
</field>
<field name="standard_price" position="before">
<group string="Automatic Price Update" colspan="2" attrs="{'invisible': [('last_purchase_price_compute_type', '!=', 'automatic_update')]}">
<field name="last_purchase_price_compute_type" readonly="1"/>
<field name="last_purchase_price_received"
<group
string="Automatic Price Update"
colspan="2"
invisible="last_purchase_price_compute_type != 'automatic_update'"
>
<field name="last_purchase_price_compute_type" readonly="1" />
<field
name="last_purchase_price_received"
widget="monetary"
options="{'currency_field': 'currency_id', 'field_digits': True}"
readonly="1"
@ -29,29 +36,38 @@
<record id="product_view_inherit_tree_price_auto" model="ir.ui.view">
<field name="name">product.template.tree.price.automatic</field>
<field name="model">product.template</field>
<field name="inherit_id" ref="product.product_template_tree_view"/>
<field name="inherit_id" ref="product.product_template_tree_view" />
<field name="arch" type="xml">
<xpath expr="//field[@name='list_price']" position="after">
<field name="list_price_theoritical" optional="hide"/>
<field name="last_purchase_price_received" optional="hide"/>
<field name="list_price_theoritical" optional="hide" />
<field name="last_purchase_price_received" optional="hide" />
</xpath>
</field>
</record>
<record id="res_config_settings_view_form_pricelists" model="ir.ui.view">
<field name="name">product.print.supermarket.res.config.settings.form</field>
<field
name="name"
>product.sale.price.pricelist.res.config.settings.form</field>
<field name="model">res.config.settings</field>
<field name="priority" eval="100" />
<field name="inherit_id" ref="sale.res_config_settings_view_form" />
<field name="arch" type="xml">
<xpath expr="//block[@id='pricing_setting_container']" position="inside">
<setting name="supermarket_settings_container">
<div class="o_setting_right_pane">
<label for="product_pricelist_automatic" string="Sale Price Pricelist" />
<field name="product_pricelist_automatic" />
<setting id="pricelist_configuration" position="after">
<setting
id="automatic_price_calculation"
string="Automatic Price from Purchase"
help="Automatically calculate product sale prices from purchase prices using a pricelist"
>
<field
name="product_pricelist_automatic"
invisible="not group_product_pricelist"
domain="[('active', '=', True)]"
/>
<div class="text-muted">
Select the pricelist used to calculate sale prices from last purchase prices
</div>
</setting>
</xpath>
</setting>
</field>
</record>
@ -64,7 +80,8 @@
<field name="arch" type="xml">
<xpath expr="//filter[@name='services']" position="before">
<separator />
<filter string="To update sales price"
<filter
string="To update sales price"
name="products_updated_filter"
domain="[('last_purchase_price_updated', '=', True), ('last_purchase_price_compute_type', '!=', 'manual_update')]"
/>