[FIX] purchase: get supplier from the procurement company
The seller_id field is a related that is read administrator so it would fetch the first line, whatever the company specified. Setting related_sudo=False would not be enough as creating purchase orders through the scheduler makes the computation done as administrator. Use the company of the procurement (required) to search for a supplier. If no result, fallback on the first one as before. Fixes #3833, opw 618809
This commit is contained in:
parent
c62be6167a
commit
20e3f33ebd
|
@ -1276,6 +1276,11 @@ class procurement_order(osv.osv):
|
|||
|
||||
def _get_product_supplier(self, cr, uid, procurement, context=None):
|
||||
''' returns the main supplier of the procurement's product given as argument'''
|
||||
supplierinfo = self.pool['product.supplierinfo']
|
||||
company_supplier = supplierinfo.search(cr, uid,
|
||||
[('product_tmpl_id', '=', procurement.product_id.product_tmpl_id.id), ('company_id', '=', procurement.company_id.id)], limit=1, context=context)
|
||||
if company_supplier:
|
||||
return supplierinfo.browse(cr, uid, company_supplier[0], context=context).name
|
||||
return procurement.product_id.seller_id
|
||||
|
||||
def _get_po_line_values_from_proc(self, cr, uid, procurement, partner, company, schedule_date, context=None):
|
||||
|
|
Loading…
Reference in New Issue