[FIX] stock_picking_batch: Add_to_batch wizard

When selecting the "Add to batch" wizard, if a user selected "Add to an
existing batch transfer", the only batches appearing there would be only
draft batches, while it could be added to in_progress batches as well.
It also displayed waves transfers with the batches, so it now only shows
batches.

Also restricted the creation of a batch in the related field since there
is an explicit option to create a new batch transfer.

Somewhat the same for the "Add to wave" wizard as it would display
cancelled waves as well.

Part of task-2985735

closes odoo/odoo#102715

X-original-commit: a8db2c5fe4b2ea1f28c6ea788ac1976678da11aa
Signed-off-by: Arnold Moyaux (arm) <arm@odoo.com>
Signed-off-by: Quentin Wolfs (quwo) <quwo@odoo.com>
This commit is contained in:
clesgow
2022-10-10 09:48:06 +02:00
parent 28a2c49d42
commit e6e55f51bc
4 changed files with 6 additions and 6 deletions
@@ -27,7 +27,7 @@ class StockPickingToWave(models.TransientModel):
raise UserError(_("The selected transfers should belong to the same operation type"))
return res
wave_id = fields.Many2one('stock.picking.batch', string='Wave Transfer', domain="[('is_wave', '=', True), ('state', '!=', 'done')]")
wave_id = fields.Many2one('stock.picking.batch', string='Wave Transfer', domain="[('is_wave', '=', True), ('state', 'in', ('draft', 'in_progress'))]")
picking_ids = fields.Many2many('stock.picking')
line_ids = fields.Many2many('stock.move.line')
mode = fields.Selection([('existing', 'an existing wave transfer'), ('new', 'a new wave transfer')], default='existing')
@@ -10,8 +10,8 @@
<group>
<label for="mode" string="Add to"/>
<field name="mode" widget="radio" nolabel="1"/>
<field name="wave_id" options="{'no_create_edit': True, 'no_open': True}" attrs="{'invisible': [('mode', '=', 'new')], 'required': [('mode', '=', 'existing')]}"/>
<field name="user_id" options="{'no_create_edit': True}" attrs="{'invisible': [('mode', '=', 'existing')]}"/>
<field name="wave_id" options="{'no_create': True, 'no_open': True}" attrs="{'invisible': [('mode', '=', 'new')], 'required': [('mode', '=', 'existing')]}"/>
<field name="user_id" options="{'no_create': True}" attrs="{'invisible': [('mode', '=', 'existing')]}"/>
</group>
</group>
@@ -9,7 +9,7 @@ class StockPickingToBatch(models.TransientModel):
_name = 'stock.picking.to.batch'
_description = 'Batch Transfer Lines'
batch_id = fields.Many2one('stock.picking.batch', string='Batch Transfer', domain="[('state', '=', 'draft')]")
batch_id = fields.Many2one('stock.picking.batch', string='Batch Transfer', domain="[('is_wave', '=', False), ('state', 'in', ('draft', 'in_progress'))]")
mode = fields.Selection([('existing', 'an existing batch transfer'), ('new', 'a new batch transfer')], default='new')
user_id = fields.Many2one('res.users', string='Responsible')
is_create_draft = fields.Boolean(string="Draft", help='When checked, create the batch in draft status')
@@ -11,8 +11,8 @@
<group>
<label for="mode" string="Add to"/>
<field name="mode" widget="radio" nolabel="1"/>
<field name="batch_id" options="{'no_create_edit': True, 'no_open': True}" attrs="{'invisible': [('mode', '=', 'new')], 'required': [('mode', '=', 'existing')]}"/>
<field name="user_id" options="{'no_create_edit': True}" attrs="{'invisible': [('mode', '=', 'existing')]}"/>
<field name="batch_id" options="{'no_create': True, 'no_open': True}" attrs="{'invisible': [('mode', '=', 'new')], 'required': [('mode', '=', 'existing')]}"/>
<field name="user_id" options="{'no_create': True}" attrs="{'invisible': [('mode', '=', 'existing')]}"/>
<field name="is_create_draft" attrs="{'invisible': [('mode', '!=', 'new')]}"/>
</group>
</group>