[FIX] sale: add force_save to make sure SO is correct

This commit implements the same fix already made in commit https://github.com/odoo/odoo/commit/a5ca63c83beafd9a060ac58d3b4c6a9a987b28df, but this time applied to the tree view of the sale order lines, instead of the form view.

Without this fix, if you add new lines in the sale order by using the tree view (instead of the form) you can get the following error:

```
Odoo Server Error - Validation Error
The operation cannot be completed, probably due to the following:
- deletion: you may be trying to delete a record while other records still reference it
- creation/update: a mandatory field is not correctly set

[object with reference: product_id - product.id]
```

The error is because the "product_id" value is not sent to the server. The "product_id" value is mandatory for sale order lines.

To reproduce the issue, you need to reproduce the following scenario:

- create a new sale order and save it
- edit the sale order; you should be able to edit inline the sale order lines (by the tree view)
- create a new product, being sure that the field 'product_id' is readonly (field 'product_updatable' is False).
- try save the sale order

See detailed explanation of the issue in description of commit https://github.com/odoo/odoo/commit/a5ca63c83beafd9a060ac58d3b4c6a9a987b28df.

PR  #21211
This commit is contained in:
Andrea Stirpe
2017-11-27 09:04:09 +01:00
committed by Géry Debongnie
parent cc560531b9
commit 2ef42e311c
+1
View File
@@ -262,6 +262,7 @@
<field name="sequence" widget="handle"/>
<field name="product_id"
attrs="{'readonly': ['|', ('qty_invoiced', '&gt;', 0), ('procurement_ids', '!=', [])]}"
force_save="1"
context="{'partner_id':parent.partner_id, 'quantity':product_uom_qty, 'pricelist':parent.pricelist_id, 'uom':product_uom, 'company_id': parent.company_id}"
/>
<field name="layout_category_id" groups="sale.group_sale_layout"/>