[FIX] product, purchase: pricelist of PO issued from procurements
When a purchase order is created through a procurement order, the purchase order pricelist is taken from the partner `property_product_pricelist_purchase`, which is a property, which therefore can be different according to the company. This is therefore important to force the company to the procurement company when browsing the partner, to get the correct pricelist, from the right company. Otherwise, it take the pricelist from the `SUPERUSER` company (when running the schedulers/cron), which can be different than the procurement company. The same as to be applied when browsing the product, as the `standard_price` field (Cost Price) is a property as well, and can be different according to the company, in order to get the correct price unit on the purchase order line, from the correct company. Fixes #5329 Closes #5330
This commit is contained in:
parent
d96050d3e0
commit
a4e48d4c28
|
@ -625,7 +625,7 @@ class product_template(osv.osv):
|
|||
if ptype != 'standard_price':
|
||||
res[product.id] = product[ptype] or 0.0
|
||||
else:
|
||||
company_id = product.env.user.company_id.id
|
||||
company_id = context.get('force_company') or product.env.user.company_id.id
|
||||
product = product.with_context(force_company=company_id)
|
||||
res[product.id] = res[product.id] = product.sudo()[ptype]
|
||||
if ptype == 'list_price':
|
||||
|
|
|
@ -1412,7 +1412,7 @@ class procurement_order(osv.osv):
|
|||
qty = uom_obj._compute_qty(cr, uid, procurement.product_uom.id, procurement.product_qty, uom_id)
|
||||
if seller_qty:
|
||||
qty = max(qty, seller_qty)
|
||||
price = pricelist_obj.price_get(cr, uid, [pricelist_id], procurement.product_id.id, qty, partner.id, {'uom': uom_id})[pricelist_id]
|
||||
price = pricelist_obj.price_get(cr, uid, [pricelist_id], procurement.product_id.id, qty, partner.id, dict(context, uom=uom_id))[pricelist_id]
|
||||
|
||||
#Passing partner_id to context for purchase order line integrity of Line name
|
||||
new_context = context.copy()
|
||||
|
@ -1495,14 +1495,15 @@ class procurement_order(osv.osv):
|
|||
linked_po_ids = []
|
||||
sum_po_line_ids = []
|
||||
for procurement in self.browse(cr, uid, ids, context=context):
|
||||
partner = self._get_product_supplier(cr, uid, procurement, context=context)
|
||||
ctx_company = dict(context or {}, force_company=procurement.company_id.id)
|
||||
partner = self._get_product_supplier(cr, uid, procurement, context=ctx_company)
|
||||
if not partner:
|
||||
self.message_post(cr, uid, [procurement.id], _('There is no supplier associated to product %s') % (procurement.product_id.name))
|
||||
res[procurement.id] = False
|
||||
else:
|
||||
schedule_date = self._get_purchase_schedule_date(cr, uid, procurement, company, context=context)
|
||||
purchase_date = self._get_purchase_order_date(cr, uid, procurement, company, schedule_date, context=context)
|
||||
line_vals = self._get_po_line_values_from_proc(cr, uid, procurement, partner, company, schedule_date, context=context)
|
||||
line_vals = self._get_po_line_values_from_proc(cr, uid, procurement, partner, company, schedule_date, context=ctx_company)
|
||||
#look for any other draft PO for the same supplier, to attach the new line on instead of creating a new draft one
|
||||
available_draft_po_ids = po_obj.search(cr, uid, [
|
||||
('partner_id', '=', partner.id), ('state', '=', 'draft'), ('picking_type_id', '=', procurement.rule_id.picking_type_id.id),
|
||||
|
|
Loading…
Reference in New Issue