[FIX] account_asset: avoid company mismatch
It was possible to change manually the company of an asset, although its category would be belonging to another company and thus its depreciation lines and journal items also. To tackle this problem, we set the company_id field of an asset as related to its category Was PR #23498. Courtesy of Miquel Raïch
This commit is contained in:
committed by
De Paoli Quentin
parent
33704bc717
commit
0c76bd3c63
@@ -72,8 +72,7 @@ class AccountAssetAsset(models.Model):
|
||||
value = fields.Float(string='Gross Value', required=True, readonly=True, digits=0, states={'draft': [('readonly', False)]}, oldname='purchase_value')
|
||||
currency_id = fields.Many2one('res.currency', string='Currency', required=True, readonly=True, states={'draft': [('readonly', False)]},
|
||||
default=lambda self: self.env.user.company_id.currency_id.id)
|
||||
company_id = fields.Many2one('res.company', string='Company', required=True, readonly=True, states={'draft': [('readonly', False)]},
|
||||
default=lambda self: self.env['res.company']._company_default_get('account.asset.asset'))
|
||||
company_id = fields.Many2one('res.company', string='Company', readonly=True, related="category_id.company_id", store=True)
|
||||
note = fields.Text()
|
||||
category_id = fields.Many2one('account.asset.category', string='Category', required=True, change_default=True, readonly=True, states={'draft': [('readonly', False)]})
|
||||
date = fields.Date(string='Date', required=True, readonly=True, states={'draft': [('readonly', False)]}, default=fields.Date.context_today, oldname="purchase_date")
|
||||
|
||||
Reference in New Issue
Block a user