[FIX] inter_company_rules: use correct sequence and warehouse
With:
- Two companies 'Company A' & 'Company B'
- Sequences for SO & PO for each company
- `so_from_po` & `po_from_so` set to True for both companies
When:
- Company A created a PO with Company B as supplier, and validated it,
- A SO was created for Company B, but with the sequence of Company A
- And the warehouse of company A
- Potentially, any fields that are company dependent (e.g. pricelist)
used Company A
- Company A created a SO with Company B as customer, and validated it,
- A PO was created for company B, but with the sequence of Company A
- Potentially, any fields that are company dependent (e.g. pricelist)
used Company A
This revision now ensure to force the right company for sequences
and properties field.
opw-649378
This commit is contained in:
@@ -30,6 +30,7 @@ class purchase_order(models.Model):
|
||||
:param company : the company of the created PO
|
||||
:rtype company : res.company record
|
||||
"""
|
||||
self = self.with_context(force_company=company.id)
|
||||
SaleOrder = self.env['sale.order']
|
||||
company_partner = self.company_id.partner_id
|
||||
|
||||
@@ -75,9 +76,13 @@ class purchase_order(models.Model):
|
||||
:rtype direct_delivery_address : res.partner record
|
||||
"""
|
||||
partner_addr = partner.sudo().address_get(['default', 'invoice', 'delivery', 'contact'])
|
||||
warehouse = company.warehouse_id and company.warehouse_id.company_id.id == company.id and company.warehouse_id or False
|
||||
if not warehouse:
|
||||
raise Warning(_('Configure correct warehouse for company(%s) from Menu: Settings/companies/companies' % (company.name)))
|
||||
return {
|
||||
'name': self.env['ir.sequence'].sudo().next_by_code('sale.order') or '/',
|
||||
'company_id': company.id,
|
||||
'warehouse_id': warehouse.id,
|
||||
'client_order_ref': name,
|
||||
'partner_id': partner.id,
|
||||
'pricelist_id': partner.property_product_pricelist.id,
|
||||
|
||||
@@ -31,6 +31,7 @@ class sale_order(models.Model):
|
||||
:param company : the company of the created PO
|
||||
:rtype company : res.company record
|
||||
"""
|
||||
self = self.with_context(force_company=company.id)
|
||||
PurchaseOrder = self.env['purchase.order']
|
||||
company_partner = self.company_id and self.company_id.partner_id or False
|
||||
if not company or not company_partner.id:
|
||||
|
||||
Reference in New Issue
Block a user