[IMP] stock: allow to customize picking values

Before this commit, It was not possible to customize Picking values.

With this commit, we add a new method which Prepares to Picking values.

closes odoo/odoo#70494

Signed-off-by: Rémy Voet <ryv-odoo@users.noreply.github.com>
This commit is contained in:
Swapnesh
2021-05-10 16:00:55 +00:00
parent 6f71999253
commit 73c7db557b
+12 -8
View File
@@ -110,20 +110,24 @@ class ReturnPicking(models.TransientModel):
}
return vals
def _prepare_picking_default_values(self):
return {
'move_lines': [],
'picking_type_id': self.picking_id.picking_type_id.return_picking_type_id.id or self.picking_id.picking_type_id.id,
'state': 'draft',
'origin': _("Return of %s") % self.picking_id.name,
'location_id': self.picking_id.location_dest_id.id,
'location_dest_id': self.location_id.id
}
def _create_returns(self):
# TODO sle: the unreserve of the next moves could be less brutal
for return_move in self.product_return_moves.mapped('move_id'):
return_move.move_dest_ids.filtered(lambda m: m.state not in ('done', 'cancel'))._do_unreserve()
# create new picking for returned products
picking_type_id = self.picking_id.picking_type_id.return_picking_type_id.id or self.picking_id.picking_type_id.id
new_picking = self.picking_id.copy({
'move_lines': [],
'picking_type_id': picking_type_id,
'state': 'draft',
'origin': _("Return of %s", self.picking_id.name),
'location_id': self.picking_id.location_dest_id.id,
'location_dest_id': self.location_id.id})
new_picking = self.picking_id.copy(self._prepare_picking_default_values())
picking_type_id = new_picking.picking_type_id.id
new_picking.message_post_with_view('mail.message_origin_link',
values={'self': new_picking, 'origin': self.picking_id},
subtype_id=self.env.ref('mail.mt_note').id)