[FIX] purchase, stock_dropshipping: origin in PO

When a product is in "dropshipping" with one supplier and with a few SO
created for the same customer, the origin of the resulting PO must
include all the SO names.

opw:647409
This commit is contained in:
Goffin Simon 2015-08-17 15:41:34 +02:00
parent 41929bd997
commit ad253a3386
2 changed files with 13 additions and 0 deletions

View File

@ -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)

View File

@ -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})