diff options
| author | Martin Trigaux <mat@odoo.com> | 2015-12-01 14:50:37 +0100 |
|---|---|---|
| committer | Martin Trigaux <mat@odoo.com> | 2015-12-01 15:23:46 +0100 |
| commit | 44eeb387d3677d4d47b6c8adebacf511cc322ded (patch) | |
| tree | c82ee42cb28a3db730f807e6b9023e4438d95c79 /addons | |
| parent | 1cd03ed7fe4b68df256e54bc72fe12841726a980 (diff) | |
[FIX] purchase: updating existing PO should keep origin
When a make to order product is sold, a purchase order is created or added to an
existing one. In the second case, the origin of the sale order was lost.
It is now added to the existing source.
opw 656688
Diffstat (limited to 'addons')
| -rw-r--r-- | addons/purchase/purchase.py | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/addons/purchase/purchase.py b/addons/purchase/purchase.py index d44bbfa110a..8e7fff2a705 100644 --- a/addons/purchase/purchase.py +++ b/addons/purchase/purchase.py @@ -1506,9 +1506,12 @@ class procurement_order(osv.osv): if available_draft_po_ids: po_id = available_draft_po_ids[0] po_rec = po_obj.browse(cr, uid, po_id, context=context) + + po_to_update = {'origin': po_rec.origin and ', '.join([po_rec.origin, procurement.origin]) or procurement.origin} #if the product has to be ordered earlier those in the existing PO, we replace the purchase date on the order to avoid ordering it too late if datetime.strptime(po_rec.date_order, DEFAULT_SERVER_DATETIME_FORMAT) > purchase_date: - po_obj.write(cr, uid, [po_id], {'date_order': purchase_date.strftime(DEFAULT_SERVER_DATETIME_FORMAT)}, context=context) + po_to_update.update({'date_order': purchase_date.strftime(DEFAULT_SERVER_DATETIME_FORMAT)}) + po_obj.write(cr, uid, [po_id], po_to_update, context=context) #look for any other PO line in the selected PO with same product and UoM to sum quantities instead of creating a new po line available_po_line_ids = po_line_obj.search(cr, uid, [('order_id', '=', po_id), ('product_id', '=', line_vals['product_id']), ('product_uom', '=', line_vals['product_uom'])], context=context) if available_po_line_ids: |
