[FIX] stock: user-default picking return
- Activate Developer mode - Go to Settings / Technical / Actions / User-defined Defaults - Create the following: Field: To Refund (update SO/PO) (stock.return.picking.line) Default Value (JSON format): true - Create a SO with a product invoiced based on delivered quantity - Validate the SO, validate the picking - Return the picking The field 'To Refund (update SO/PO)' is is not, while it should be. This is because we don't explicitly call the `default_get`, therefore only rely on the default value of the field. opw-2172513 closes odoo/odoo#45235 X-original-commit: 70d6f25b83f962d91243edaa0ff8e9a78b2e18ac Signed-off-by: Nicolas Martinelli (nim) <nim@odoo.com>
This commit is contained in:
@@ -49,6 +49,10 @@ class ReturnPicking(models.TransientModel):
|
||||
product_return_moves = [(5,)]
|
||||
if self.picking_id and self.picking_id.state != 'done':
|
||||
raise UserError(_("You may only return Done pickings."))
|
||||
# In case we want to set specific default values (e.g. 'to_refund'), we must fetch the
|
||||
# default values for creation.
|
||||
line_fields = [f for f in self.env['stock.return.picking.line']._fields.keys()]
|
||||
product_return_moves_data_tmpl = self.env['stock.return.picking.line'].default_get(line_fields)
|
||||
for move in self.picking_id.move_lines:
|
||||
if move.state == 'cancel':
|
||||
continue
|
||||
@@ -56,7 +60,9 @@ class ReturnPicking(models.TransientModel):
|
||||
continue
|
||||
if move.move_dest_ids:
|
||||
move_dest_exists = True
|
||||
product_return_moves.append((0, 0, self._prepare_stock_return_picking_line_vals_from_move(move)))
|
||||
product_return_moves_data = dict(product_return_moves_data_tmpl)
|
||||
product_return_moves_data.update(self._prepare_stock_return_picking_line_vals_from_move(move))
|
||||
product_return_moves.append((0, 0, product_return_moves_data))
|
||||
if self.picking_id and not product_return_moves:
|
||||
raise UserError(_("No products to return (only lines in Done state and not fully returned yet can be returned)."))
|
||||
if self.picking_id:
|
||||
|
||||
Reference in New Issue
Block a user