[FIX] stock, sale_stock: copy the to_refund field when splitting a move

The to_refund attribute is set to copy=False.
However when splitting a move to create a backorder, a new move is created as
a copy with the remaining work to do.
This attribute is needed so that the backorder refund is consistently applied.

Essentially a backport of commit:
https://github.com/odoo/odoo/commit/c5ffca151160f9d99bec036330def108e4e91e0b

opw 1865324
This commit is contained in:
len-odoo
2018-08-08 08:49:11 +02:00
committed by len-odoo
parent bec639c094
commit 0ab71f1247
2 changed files with 12 additions and 0 deletions
+5
View File
@@ -40,6 +40,11 @@ class StockMove(models.Model):
subtype_id=self.env.ref('mail.mt_note').id)
return result
def _prepare_move_split_vals(self, defaults):
defaults = super(StockMove, self)._prepare_move_split_vals(defaults)
defaults['to_refund_so'] = self.to_refund_so
return defaults
class StockPicking(models.Model):
_inherit = 'stock.picking'
+7
View File
@@ -938,6 +938,10 @@ class StockMove(models.Model):
new_move_prop = self.move_dest_id.split(qty)
new_move.write({'move_dest_id': new_move_prop})
def _prepare_move_split_vals(self, defaults):
# hook to add values in default vals in other modules
return defaults
@api.multi
def split(self, qty, restrict_lot_id=False, restrict_partner_id=False):
""" Splits qty from move move into a new move
@@ -967,6 +971,9 @@ class StockMove(models.Model):
'move_dest_id': self.move_dest_id.id,
'origin_returned_move_id': self.origin_returned_move_id.id,
}
defaults = self._prepare_move_split_vals(defaults)
if restrict_partner_id:
defaults['restrict_partner_id'] = restrict_partner_id