[FIX] inter_company_rules : misplaced sudo to prepare value to create PO/SO lines
The initial problem is when generating a PO from SO (or the inverse) the taxes were not propagated to the new created line. Taxes are company dependent field : so when we create a PO in company A, the PO line contains the taxes of company A, but we want the corresponding SO line in company B to have the taxes of company B, which wasn't the case. This commit makes the taxes propagation works. The initial line is now browse as sudo() to get all the taxes related to this line (or its product). Then we filter them to keep only the ones from the right company. Do not forward port this commit, since the same patch will be applied in 9.0e
This commit is contained in:
@@ -51,8 +51,9 @@ class purchase_order(models.Model):
|
||||
# read it as sudo, because inter-compagny user can not have the access right on PO
|
||||
sale_order_data = self.sudo()._prepare_sale_order_data(self.name, company_partner, company, self.dest_address_id and self.dest_address_id.id or False)
|
||||
sale_order = SaleOrder.sudo(intercompany_uid).create(sale_order_data[0])
|
||||
for line in self.order_line:
|
||||
so_line_vals = self.sudo()._prepare_sale_order_line_data(line, company, sale_order.id)
|
||||
# lines are browse as sudo to access all data required to be copied on SO line (mainly for company dependent field like taxes)
|
||||
for line in self.order_line.sudo():
|
||||
so_line_vals = self._prepare_sale_order_line_data(line, company, sale_order.id)
|
||||
SaleOrderLine.sudo(intercompany_uid).create(so_line_vals)
|
||||
|
||||
# write supplier reference field on PO
|
||||
|
||||
@@ -54,8 +54,8 @@ class sale_order(models.Model):
|
||||
# read it as sudo, because inter-compagny user can not have the access right on PO
|
||||
po_vals = self.sudo()._prepare_purchase_order_data(company, company_partner)
|
||||
purchase_order = PurchaseOrder.sudo(intercompany_uid).create(po_vals[0])
|
||||
for line in self.order_line:
|
||||
po_line_vals = self.sudo()._prepare_purchase_order_line_data(line, self.date_order, purchase_order.id, company)
|
||||
for line in self.order_line.sudo():
|
||||
po_line_vals = self._prepare_purchase_order_line_data(line, self.date_order, purchase_order.id, company)
|
||||
PurchaseOrderLine.sudo(intercompany_uid).create(po_line_vals)
|
||||
|
||||
# write customer reference field on SO
|
||||
|
||||
Reference in New Issue
Block a user