[FIX] stock: always read field for default_order in move.line tree

Previous PR odoo/odoo#143570 moved some move line ordering logic from the
model to the view to avoid recomputing of these fields since it was
causing issues with the computes occurring at the wrong time.
Unfortunately every field used in the `default_order` in the view has to
be present in the view and since v16 any fields that have a groups
attribute that isn't met isn't loaded in the view.

Therefore we have to force the `result_package_id` to always be in the
view even if `stock.group_tracking_lot` is not true (i.e. packages are
active)

Steps to reproduce:
- create +save a receipt with a tracked product
- click on the burger button to open the detailed operations of the
  tracked product
- add 2 move lines + Confirm

Expected behavior:
the move lines save

Actual behavior:
JS traceback due to trying to sort on a field that isn't present in the
view

closes odoo/odoo#147188

Signed-off-by: Quentin Wolfs (quwo) <quwo@odoo.com>
Signed-off-by: Tiffany Chang (tic) <tic@odoo.com>
This commit is contained in:
Tiffany Chang (tic)
2023-12-27 11:21:39 +00:00
parent ab0b9d1403
commit b53d3cd726
+2
View File
@@ -196,6 +196,7 @@
<field name="location_id" column_invisible="True"/>
<field name="location_dest_id" column_invisible="True"/>
<field name="package_id" column_invisible="True"/>
<field name="result_package_id" column_invisible="True"/>
<field name="tracking" column_invisible="True"/>
<field name="picking_type_id" column_invisible="True"/>
<field name="product_uom_id" column_invisible="True" groups="!uom.group_uom"/>
@@ -264,6 +265,7 @@
<field name="lot_name" column_invisible="not context.get('show_lots_text')" groups="stock.group_production_lot" invisible="not lots_visible" context="{'default_product_id': product_id}"/>
<field name="location_dest_id" options="{'no_create': True}" column_invisible="context.get('picking_code') == 'outgoing'" groups="stock.group_stock_multi_locations" domain="[('id', 'child_of', picking_location_dest_id), '|', ('company_id', '=', False), ('company_id', '=', company_id), ('usage', '!=', 'view')]"/>
<field name="package_id" column_invisible="True"/>
<field name="result_package_id" column_invisible="True"/>
<field name="result_package_id" groups="stock.group_tracking_lot"/>
<field name="lots_visible" column_invisible="True"/>
<field name="owner_id" groups="stock.group_tracking_owner" column_invisible="context.get('picking_code') == 'incoming'"/>