[FIX] website_sale: filter fiscal positions on company v2

Sequel of cc54194e13.
The mentioned fix only worked when the user was public.

The problem arises when calling the function `_get_fpos_by_region()`
in `sudo` without specifying the company and this happens, for instance,
in every `onchange_partner_*` function of a sale order.

We propose to add the `force_company` key in the context of the sale
order to ensure the right company when selecting the fiscal position.

closes odoo/odoo#31751

Signed-off-by: Rémi Rahir (rar) <rar@odoo.com>
This commit is contained in:
Rémi Rahir
2019-03-11 14:57:21 +00:00
parent 084246a54e
commit 49ca43d75c
+1 -1
View File
@@ -390,7 +390,7 @@ class Website(models.Model):
# TODO cache partner_id session
pricelist = self.env['product.pricelist'].browse(pricelist_id).sudo()
so_data = self._prepare_sale_order_values(partner, pricelist)
sale_order = self.env['sale.order'].sudo().create(so_data)
sale_order = self.env['sale.order'].with_context(force_company=request.website.company_id.id).sudo().create(so_data)
# set fiscal position
if request.website.partner_id.id != partner.id: