[FIX] stock: decrease initial demand quantity

- Open a picking (example WH/IN/00002)
- Unlock
- Edit Initial Demand (from 35 to 4 for example)
- Click on Save

An error occurs: 'Record does not exist or has been deleted.'

When saving, the following values are sent to the server (example):
`{'move_ids_without_package': [
     [1, 31, {'product_uom_qty': 4, 'date_expected': '2018-10-02 08:27:14'}]
 ],
 'move_line_ids_without_package': [
     [1, 26, {'package_id': False, 'result_package_id': False, 'owner_id': False, 'lot_id': False}]
 ]}`

The field `move_ids_without_package` contains the new quantity. However,
decreasing the quantity will remove the reservation and therefore unlink
the move lines.

https://github.com/odoo/odoo/blob/718b0f8b63261e1312b5626d48de050b21a9dccf/addons/stock/models/stock_move_line.py#L349

This means that the field `move_line_ids_without_package` refers to IDs
which have been deleted when writing on `move_ids_without_package`.

We can make the field read-only if it is not displayed.

opw-1889802
This commit is contained in:
Nicolas Martinelli
2018-10-02 12:55:36 +02:00
committed by Nicolas Martinelli
parent 532d82a7a9
commit cdf201a1dc
+1 -1
View File
@@ -265,7 +265,7 @@
</group>
<notebook>
<page string="Detailed Operations" attrs="{'invisible': [('show_operations', '=', False)]}">
<field name="move_line_ids_without_package" attrs="{'readonly': ['|', ('state', '=', 'cancel'), '&amp;', ('state', '=', 'done'), ('is_locked', '=', True)]}" context="{'default_picking_id': id, 'default_location_id': location_id, 'default_location_dest_id': location_dest_id}">
<field name="move_line_ids_without_package" attrs="{'readonly': ['|', '|', ('show_operations', '=', False), ('state', '=', 'cancel'), '&amp;', ('state', '=', 'done'), ('is_locked', '=', True)]}" context="{'default_picking_id': id, 'default_location_id': location_id, 'default_location_dest_id': location_dest_id}">
<tree editable="bottom" decoration-muted="(state == 'done' and is_locked == True)" decoration-danger="qty_done&gt;product_uom_qty and state!='done'" decoration-success="qty_done==product_uom_qty and state!='done' and not result_package_id">
<field name="product_id" required="1" attrs="{'readonly': ['|', ('state', '=', 'done'), ('move_id', '!=', False)]}"/>
<field name="move_id" invisible="1"/>