[FIX] sale: add force_save on product_uom in views

Create a sale order. Confirm it. Add a new line. Change the UoM on this line.
The onchange is applied, modifying the unit price.
Save: the saved product UoM is the default one.

So for example if the user changes the UoM from day to hours,
he will sell one day for the price of one hour.

This is because the field product_uom is set to read_only if the state of the
sale order is confirmed ('sale') (as well as if the state is 'done' or 'cancel')
However it is still possible to change it when adding a new line.

opw 1923534

closes odoo/odoo#30420
This commit is contained in:
Nans Lefebvre
2019-01-22 07:36:40 +00:00
parent 16b873c771
commit 102467ae23
+2
View File
@@ -261,6 +261,7 @@
context="{'partner_id':parent.partner_id, 'quantity':product_uom_qty, 'pricelist':parent.pricelist_id, 'uom':product_uom, 'uom_qty_change':True, 'company_id': parent.company_id}"
name="product_uom_qty" class="oe_inline"/>
<field name="product_uom" groups="product.group_uom" class="oe_inline oe_no_button"
force_save="1"
attrs="{'readonly': [('state', 'in', ('sale','done', 'cancel'))]}"/>
</div>
<label for="qty_delivered" string="Delivered Quantity" attrs="{'invisible': [('parent.state', 'not in', ['sale', 'done'])]}"/>
@@ -318,6 +319,7 @@
attrs="{'column_invisible': [('parent.state', 'not in', ['sale', 'done'])]}"/>
<field name="qty_to_invoice" invisible="1"/>
<field name="product_uom"
force_save="1"
attrs="{'readonly': [('state', 'in', ('sale','done', 'cancel'))]}"
context="{'company_id': parent.company_id}"
groups="product.group_uom" options='{"no_open": True}'/>