From 8308dcd34619a35506bd49e52adb6b3ef6860022 Mon Sep 17 00:00:00 2001 From: Simon Lejeune Date: Fri, 9 Jun 2017 17:16:18 +0200 Subject: [PATCH] [REF] purchase: adapt to new stock implementation --- addons/purchase/models/purchase.py | 6 +++--- addons/stock/models/stock_move.py | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/addons/purchase/models/purchase.py b/addons/purchase/models/purchase.py index ab20bd31081..1c5ec88759f 100644 --- a/addons/purchase/models/purchase.py +++ b/addons/purchase/models/purchase.py @@ -407,7 +407,7 @@ class PurchaseOrder(models.Model): picking = pickings[0] moves = order.order_line._create_stock_moves(picking) moves = moves.filtered(lambda x: x.state not in ('done', 'cancel')).action_confirm() - moves.force_assign() + moves.action_assign() picking.message_post_with_view('mail.message_origin_link', values={'self': picking, 'origin': order}, subtype_id=self.env.ref('mail.mt_note').id) @@ -656,7 +656,7 @@ class PurchaseOrderLine(models.Model): 'location_dest_id': self.order_id._get_destination_location(), 'picking_id': picking.id, 'partner_id': self.order_id.dest_address_id.id, - 'move_dest_id': False, + 'move_dest_ids': False, 'state': 'draft', 'purchase_line_id': self.id, 'company_id': self.order_id.company_id.id, @@ -679,7 +679,7 @@ class PurchaseOrderLine(models.Model): tmp = template.copy() tmp.update({ 'product_uom_qty': min(procurement_qty, diff_quantity), - 'move_dest_id': procurement.move_dest_id.id, # move destination is same as procurement destination + 'move_dest_ids': procurement.move_dest_id and [(4, procurement.move_dest_id.id)] or [], # move destination is same as procurement destination 'procurement_id': procurement.id, 'propagate': procurement.rule_id.propagate, }) diff --git a/addons/stock/models/stock_move.py b/addons/stock/models/stock_move.py index 83b57949fb4..27d44b3d81a 100644 --- a/addons/stock/models/stock_move.py +++ b/addons/stock/models/stock_move.py @@ -378,13 +378,13 @@ class StockMove(models.Model): new_date = datetime.strptime(vals.get(propagated_date_field), DEFAULT_SERVER_DATETIME_FORMAT) delta = new_date - current_date if abs(delta.days) >= move.company_id.propagation_minimum_delta: - old_move_date = datetime.strptime(move.move_dest_id.date_expected, DEFAULT_SERVER_DATETIME_FORMAT) + old_move_date = datetime.strptime(move.move_dest_ids[0].date_expected, DEFAULT_SERVER_DATETIME_FORMAT) new_move_date = (old_move_date + relativedelta.relativedelta(days=delta.days or 0)).strftime(DEFAULT_SERVER_DATETIME_FORMAT) propagated_changes_dict['date_expected'] = new_move_date #For pushed moves as well as for pulled moves, propagate by recursive call of write(). #Note that, for pulled moves we intentionally don't propagate on the procurement. if propagated_changes_dict: - move.move_dest_id.write(propagated_changes_dict) + move.move_dest_ids.filtered(lambda m: m.state not in ('done', 'cancel')).write(propagated_changes_dict) track_pickings = not self._context.get('mail_notrack') and any(field in vals for field in ['state', 'picking_id', 'partially_available']) if track_pickings: to_track_picking_ids = set([move.picking_id.id for move in self if move.picking_id])