From fa97d6ab1573515e6485b169df1e1f6b709275de Mon Sep 17 00:00:00 2001 From: Nicolas Martinelli Date: Wed, 6 Feb 2019 14:11:50 +0000 Subject: [PATCH] [FIX] purchase: supplier on parent company - Create a product and set a contact as the vendor (for instance, Arthur Gomez from Asustek in the runbot) - Set a specific name and code for the supplier - Create a RFQ for this vendor (Arthur Gomez - the contact person) - Add the product, confirm the RFQ On the product, the company (Asustek) is automatically added as vendor, but there is no vendor name and code. opw-1929745 closes odoo/odoo#30891 --- addons/purchase/models/purchase.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/addons/purchase/models/purchase.py b/addons/purchase/models/purchase.py index 295c434c4e2..8f80e112b32 100644 --- a/addons/purchase/models/purchase.py +++ b/addons/purchase/models/purchase.py @@ -448,6 +448,16 @@ class PurchaseOrder(models.Model): 'currency_id': currency.id, 'delay': 0, } + # In case the order partner is a contact address, a new supplierinfo is created on + # the parent company. In this case, we keep the product name and code. + seller = line.product_id._select_seller( + partner_id=line.partner_id, + quantity=line.product_qty, + date=line.order_id.date_order and line.order_id.date_order[:10], + uom_id=line.product_uom) + if seller: + supplierinfo['product_name'] = seller.product_name + supplierinfo['product_code'] = seller.product_code vals = { 'seller_ids': [(0, 0, supplierinfo)], }