[IMP] stock: correct default_get behavior
Leave the management of default_* context keys to the orm level. closes odoo/odoo#54246 Related: odoo/enterprise#11754 Signed-off-by: Victor Feyens (vfe) <vfe@odoo.com>
This commit is contained in:
@@ -28,10 +28,13 @@ class StockBackorderConfirmation(models.TransientModel):
|
||||
@api.model
|
||||
def default_get(self, fields):
|
||||
res = super().default_get(fields)
|
||||
if 'backorder_confirmation_line_ids' in fields:
|
||||
if self.env.context.get('default_pick_ids'):
|
||||
res['pick_ids'] = self.env.context['default_pick_ids']
|
||||
res['backorder_confirmation_line_ids'] = [(0, 0, {'to_backorder': True, 'picking_id': pick_id[1]}) for pick_id in res['pick_ids']]
|
||||
if 'backorder_confirmation_line_ids' in fields and res.get('pick_ids'):
|
||||
res['backorder_confirmation_line_ids'] = [
|
||||
(0, 0, {'to_backorder': True, 'picking_id': pick_id})
|
||||
for pick_id in res['pick_ids'][0][2]
|
||||
]
|
||||
# default_get returns x2m values as [(6, 0, ids)]
|
||||
# because of webclient limitations
|
||||
return res
|
||||
|
||||
def process(self):
|
||||
|
||||
@@ -15,6 +15,16 @@
|
||||
</p>
|
||||
</group>
|
||||
|
||||
<!-- Added to ensure a correct default_get behavior
|
||||
|
||||
The wizard is always opened with default_pick_ids values in context,
|
||||
which are used to generate the backorder_confirmation_line_ids.
|
||||
|
||||
To ensure default_pick_ids is correctly converted from the context
|
||||
by default_get, the field has to be present in the view.
|
||||
-->
|
||||
<field name="pick_ids" invisible="1"/>
|
||||
|
||||
<field name="show_transfers" invisible="1"/>
|
||||
<field name="backorder_confirmation_line_ids" nolabel="1" attrs="{'invisible': [('show_transfers', '=', False)]}">>
|
||||
<tree create="0" delete="0" editable="top">
|
||||
|
||||
@@ -28,10 +28,13 @@ class StockImmediateTransfer(models.TransientModel):
|
||||
@api.model
|
||||
def default_get(self, fields):
|
||||
res = super().default_get(fields)
|
||||
if 'immediate_transfer_line_ids' in fields:
|
||||
if self.env.context.get('default_pick_ids'):
|
||||
res['pick_ids'] = self.env.context['default_pick_ids']
|
||||
res['immediate_transfer_line_ids'] = [(0, 0, {'to_immediate': True, 'picking_id': pick_id[1]}) for pick_id in res['pick_ids']]
|
||||
if 'immediate_transfer_line_ids' in fields and res.get('pick_ids'):
|
||||
res['immediate_transfer_line_ids'] = [
|
||||
(0, 0, {'to_immediate': True, 'picking_id': pick_id})
|
||||
for pick_id in res['pick_ids'][0][2]
|
||||
]
|
||||
# default_get returns x2m values as [(6, 0, ids)]
|
||||
# because of webclient limitations
|
||||
return res
|
||||
|
||||
def process(self):
|
||||
|
||||
@@ -9,6 +9,16 @@
|
||||
<p>You have not recorded <i>done</i> quantities yet, by clicking on <i>apply</i> Odoo will process all the quantities.</p>
|
||||
</group>
|
||||
|
||||
<!-- Added to ensure a correct default_get behavior
|
||||
|
||||
The wizard is always opened with default_pick_ids values in context,
|
||||
which are used to generate the backorder_confirmation_line_ids.
|
||||
|
||||
To ensure default_pick_ids is correctly converted from the context
|
||||
by default_get, the field has to be present in the view.
|
||||
-->
|
||||
<field name="pick_ids" invisible="1"/>
|
||||
|
||||
<field name="show_transfers" invisible="1"/>
|
||||
<field name="immediate_transfer_line_ids" nolabel="1" attrs="{'invisible': [('show_transfers', '=', False)]}">>
|
||||
<tree create="0" delete="0" editable="top">
|
||||
|
||||
Reference in New Issue
Block a user