[REF] stock, stock_account: to_refund in return
Make `to_refund` true by default as this is ideal for most users. An override of `default_get` won't work because the field is present in the view only in debug mode. Task-1962183 closes odoo/odoo#32495 Signed-off-by: Simon Lejeune (sle) <sle@openerp.com>
This commit is contained in:
committed by
Simon Lejeune
parent
822b05d1da
commit
d9b0b09bd2
@@ -54,13 +54,7 @@ class ReturnPicking(models.TransientModel):
|
||||
continue
|
||||
if move.move_dest_ids:
|
||||
move_dest_exists = True
|
||||
quantity = move.product_qty - sum(move.move_dest_ids
|
||||
.filtered(lambda m: m.state in ['partially_available', 'assigned', 'done'])
|
||||
.mapped('move_line_ids').mapped('product_qty')
|
||||
)
|
||||
quantity = float_round(quantity, precision_rounding=move.product_uom.rounding)
|
||||
product_return_moves.append((0, 0, {'product_id': move.product_id.id, 'quantity': quantity, 'move_id': move.id, 'uom_id': move.product_id.uom_id.id}))
|
||||
|
||||
product_return_moves.append((0, 0, self._prepare_stock_return_picking_line_vals_from_move(move)))
|
||||
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:
|
||||
@@ -73,6 +67,21 @@ class ReturnPicking(models.TransientModel):
|
||||
location_id = self.picking_id.picking_type_id.return_picking_type_id.default_location_dest_id.id
|
||||
self.location_id = location_id
|
||||
|
||||
@api.model
|
||||
def _prepare_stock_return_picking_line_vals_from_move(self, stock_move):
|
||||
quantity = stock_move.product_qty - sum(
|
||||
stock_move.move_dest_ids
|
||||
.filtered(lambda m: m.state in ['partially_available', 'assigned', 'done'])
|
||||
.mapped('move_line_ids.product_qty')
|
||||
)
|
||||
quantity = float_round(quantity, precision_rounding=stock_move.product_uom.rounding)
|
||||
return {
|
||||
'product_id': stock_move.product_id.id,
|
||||
'quantity': quantity,
|
||||
'move_id': stock_move.id,
|
||||
'uom_id': stock_move.product_id.uom_id.id,
|
||||
}
|
||||
|
||||
def _prepare_move_default_values(self, return_line, new_picking):
|
||||
vals = {
|
||||
'product_id': return_line.product_id.id,
|
||||
|
||||
@@ -716,13 +716,6 @@ class StockMove(models.Model):
|
||||
class StockReturnPicking(models.TransientModel):
|
||||
_inherit = "stock.return.picking"
|
||||
|
||||
@api.model
|
||||
def default_get(self, default_fields):
|
||||
res = super(StockReturnPicking, self).default_get(default_fields)
|
||||
for i, k, vals in res.get('product_return_moves', []):
|
||||
vals.update({'to_refund': True})
|
||||
return res
|
||||
|
||||
@api.multi
|
||||
def _create_returns(self):
|
||||
new_picking_id, pick_type_id = super(StockReturnPicking, self)._create_returns()
|
||||
@@ -733,6 +726,11 @@ class StockReturnPicking(models.TransientModel):
|
||||
move.to_refund = True
|
||||
return new_picking_id, pick_type_id
|
||||
|
||||
def _prepare_stock_return_picking_line_vals_from_move(self, stock_move):
|
||||
res = super(StockReturnPicking, self)._prepare_stock_return_picking_line_vals_from_move(stock_move)
|
||||
res['to_refund'] = True
|
||||
return res
|
||||
|
||||
|
||||
class StockReturnPickingLine(models.TransientModel):
|
||||
_inherit = "stock.return.picking.line"
|
||||
|
||||
Reference in New Issue
Block a user