[ADD] purchase: auto add partner to vendors

If a product has no vendor, the partner of the PO will be added as a
vendor for the product during the confirmation of the PO.
This commit is contained in:
Nicolas Martinelli
2015-09-03 13:15:16 +02:00
parent 3f48d2b6c4
commit e4d14110ad
+16
View File
@@ -243,6 +243,22 @@ class PurchaseOrder(models.Model):
@api.multi
def button_confirm(self):
# Add the partner in the supplier list of the product if no supplier for this product
for line in self.order_line:
if not line.product_id.seller_ids:
supplierinfo = {
'name': self.partner_id.id,
'product_uom': line.product_uom.id,
'min_qty': 0.0,
'price': line.price_unit,
'currency_id': self.partner_id.currency_id.id,
'delay': 0,
}
vals = {
'seller_ids': [(0, 0, supplierinfo)],
}
line.product_id.write(vals)
# Deal with double validation process
if self.user_has_groups('purchase.group_purchase_manager'):
return self.button_approve()