[REF] purchase: adapt to new stock implementation

This commit is contained in:
Simon Lejeune
2017-07-14 17:08:21 +02:00
parent fe20747ddc
commit 8308dcd346
2 changed files with 5 additions and 5 deletions
+3 -3
View File
@@ -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,
})
+2 -2
View File
@@ -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])