diff --git a/addons/purchase/purchase.py b/addons/purchase/purchase.py index 8060e55d74b..95d4da6fe1b 100644 --- a/addons/purchase/purchase.py +++ b/addons/purchase/purchase.py @@ -1436,6 +1436,9 @@ class procurement_order(osv.osv): return qty, price + def update_origin_po(self, cr, uid, po, proc, context=None): + pass + def make_po(self, cr, uid, ids, context=None): """ Resolve the purchase from procurement, which may result in a new PO creation, a new PO line creation or a quantity change on existing PO line. Note that some operations (as the PO creation) are made as SUPERUSER because the current user may not have rights to do it (mto product launched by a sale for example) @@ -1478,6 +1481,7 @@ class procurement_order(osv.osv): if new_qty > po_line.product_qty: po_line_obj.write(cr, SUPERUSER_ID, po_line.id, {'product_qty': new_qty, 'price_unit': new_price}, context=context) + self.update_origin_po(cr, uid, po_rec, procurement, context=context) sum_po_line_ids.append(procurement.id) else: line_vals.update(order_id=po_id) diff --git a/addons/stock_dropshipping/stock_dropshipping.py b/addons/stock_dropshipping/stock_dropshipping.py index a41760820e3..f889d7427d7 100644 --- a/addons/stock_dropshipping/stock_dropshipping.py +++ b/addons/stock_dropshipping/stock_dropshipping.py @@ -43,3 +43,12 @@ class purchase_order(models.Model): if not self.env.context.get('no_invoice_policy_check'): self._check_invoice_policy() super(purchase_order, self).wkf_confirm_order() + +class procurement_order(models.Model): + _inherit = 'procurement.order' + + @api.model + def update_origin_po(self, po, proc): + super(procurement_order, self).update_origin_po(po, proc) + if proc.sale_line_id and not (proc.origin in po.origin): + po.sudo().write({'origin': po.origin+', '+proc.origin})