[FIX] stock: Wrong production/scrap/adjustment location used in multicompany
- When using perpetual inventory valuation, the accounts used for scrap, manufacturing, and inventory adjustment operations are set on the corresponding locations . - In a multicompany environment, you will have a separate chart of accounts for each company. - Account fields on locations are not property fields. - Therefore, in order to separate the accounting of manufacturing, scrap, and inventory adjustment operations, you must use a location for each operation for each company. - Set up one location for each company for scrap, production, and adjustment locations, setting the company field on each. Bug: - When attempting to create a MO, inventory adjustment, or scrap order while signed in to the second company, you will receive a permissions error on stock.location. Fix: - Now the right location is taken according to the company of the user. opw:1817339
This commit is contained in:
@@ -11,10 +11,14 @@ class StockScrap(models.Model):
|
||||
_order = 'id desc'
|
||||
|
||||
def _get_default_scrap_location_id(self):
|
||||
return self.env['stock.location'].search([('scrap_location', '=', True)], limit=1).id
|
||||
return self.env['stock.location'].search([('scrap_location', '=', True), ('company_id', 'in', [self.env.user.company_id.id, False])], limit=1).id
|
||||
|
||||
def _get_default_location_id(self):
|
||||
return self.env.ref('stock.stock_location_stock', raise_if_not_found=False)
|
||||
company_user = self.env.user.company_id
|
||||
warehouse = self.env['stock.warehouse'].search([('company_id', '=', company_user.id)], limit=1)
|
||||
if warehouse:
|
||||
return warehouse.lot_stock_id.id
|
||||
return None
|
||||
|
||||
name = fields.Char(
|
||||
'Reference', default=lambda self: _('New'),
|
||||
|
||||
Reference in New Issue
Block a user