[FIX] point_of_sale: product valuation at invoice

- Create 2 companies A & B
- Set the superuser in company A
- Create a POS and a user in company B
- Create a product P. The 'Inventory Valuation' must be different in
  both companies:
  Company A: Periodic (manual)
  Company B: Perpetual (automated)
- Connect with the user in company B
- Sell the product P, select a customer and print the invoice

The COGS journal entry is not posted.

This is because `action_invoice_open` is called as `sudo()`, but
ultimately `product.valuation` is called in:

https://github.com/odoo/odoo/blob/0cce154794c8de945805d9b9acc4c33e5258191a/addons/stock_account/models/product.py#L325

`product.valuation` is computed based on the property field
`property_valuation`, which is therefore company-dependant.

Closes #32803
opw-1961861

closes odoo/odoo#32903

Signed-off-by: Nicolas Martinelli (nim) <nim@odoo.com>
This commit is contained in:
Nicolas Martinelli
2019-04-24 09:25:42 +00:00
parent c1f354beb8
commit a2d71ce0ea
+1 -1
View File
@@ -728,7 +728,7 @@ class PosOrder(models.Model):
if to_invoice:
pos_order.action_pos_order_invoice()
pos_order.invoice_id.sudo().action_invoice_open()
pos_order.invoice_id.sudo().with_context(force_company=self.env.user.company_id.id).action_invoice_open()
pos_order.account_move = pos_order.invoice_id.move_id
return order_ids