[FIX] stock_picking_batch_custom: prevent product_id null error on summary lines

- Use regular dict instead of defaultdict to avoid empty entries
- Make summary_line_ids readonly=True to prevent UI from inserting empty lines
- Add SQL constraint CHECK(product_id IS NOT NULL) as safeguard
- Use boolean_toggle widget for is_collected field
- Fix tests to use TransactionCase and invalidate_recordset
- Add test for empty batch + add pickings + confirm flow
This commit is contained in:
snt 2026-03-05 21:47:18 +01:00
parent ad8b759643
commit 3eeca66551
5 changed files with 304 additions and 45 deletions

View file

@ -4,14 +4,14 @@
<field name="name">stock.picking.batch.summary.line.tree</field>
<field name="model">stock.picking.batch.summary.line</field>
<field name="arch" type="xml">
<list create="0" delete="0" editable="bottom" default_order="product_categ_id,product_id">
<list create="0" delete="0" default_order="product_categ_id,product_id">
<field name="product_id" readonly="1"/>
<field name="product_categ_id" readonly="1" optional="hide"/>
<field name="product_uom_id" readonly="1" optional="hide"/>
<field name="qty_demanded" readonly="1"/>
<field name="qty_done" readonly="1"/>
<field name="qty_pending" readonly="1"/>
<field name="is_collected" widget="boolean_toggle"/>
<field name="is_collected" widget="boolean_toggle" nolabel="1"/>
</list>
</field>
</record>