summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPierre Masereel <pim@odoo.com>2019-07-24 07:53:34 +0000
committerPierre Masereel <pim@odoo.com>2019-07-24 07:53:34 +0000
commit66c49dd451e8debdb3d28c22cda0d4e80b383501 (patch)
tree50a98a935da8e702dc3868ea83bf4cbde010ac0d
parent00476acea079c0e429364beadaa02756216b8a80 (diff)
[FIX] stock: use current company
Since changes made on multi-company, env.user.company_id doesn't reprsent the the current company anymore, it is only the company in which the user will be connected by default in Odoo. The current main company is now available under env.company, so we use now the current company instead of the user default. closes odoo/odoo#35129 Signed-off-by: Arnold Moyaux <amoyaux@users.noreply.github.com>
-rw-r--r--addons/stock/models/product.py2
-rw-r--r--addons/stock/models/stock_quant.py6
2 files changed, 4 insertions, 4 deletions
diff --git a/addons/stock/models/product.py b/addons/stock/models/product.py
index c1bd8f80138..2c5e895677a 100644
--- a/addons/stock/models/product.py
+++ b/addons/stock/models/product.py
@@ -422,7 +422,7 @@ class Product(models.Model):
self = self.with_context(inventory_mode=True)
# Set default location id if multilocations is inactive
if not self.user_has_groups('stock.group_stock_multi_locations'):
- user_company = self.env.user.company_id
+ user_company = self.env.company
warehouse = self.env['stock.warehouse'].search(
[('company_id', '=', user_company.id)], limit=1
)
diff --git a/addons/stock/models/stock_quant.py b/addons/stock/models/stock_quant.py
index 14c6cc77aae..603f7832643 100644
--- a/addons/stock/models/stock_quant.py
+++ b/addons/stock/models/stock_quant.py
@@ -21,7 +21,7 @@ class StockQuant(models.Model):
def _domain_location_id(self):
if not self._is_inventory_mode():
return
- return ['&', ('company_id', '=', self.env.user.company_id.id), ('usage', 'in', ['internal', 'transit'])]
+ return ['&', ('company_id', '=', self.env.company.id), ('usage', 'in', ['internal', 'transit'])]
def _domain_product_id(self):
if not self._is_inventory_mode():
@@ -170,7 +170,7 @@ class StockQuant(models.Model):
# fixme: erase the following condition when it'll be possible to create a new record
# from a empty grouped editable list without go through the form view.
if self.search_count([
- ('company_id', '=', self.env.user.company_id.id),
+ ('company_id', '=', self.env.company.id),
('location_id.usage', 'in', ['internal', 'transit'])
]):
self = self.with_context(
@@ -178,7 +178,7 @@ class StockQuant(models.Model):
search_default_locationgroup=1
)
if not self.user_has_groups('stock.group_stock_multi_locations'):
- company_user = self.env.user.company_id
+ company_user = self.env.company
warehouse = self.env['stock.warehouse'].search([('company_id', '=', company_user.id)], limit=1)
if warehouse:
self = self.with_context(default_location_id=warehouse.lot_stock_id.id)