diff options
| author | Olivier Laurent <olt@odoo.com> | 2015-09-09 13:21:43 +0200 |
|---|---|---|
| committer | Olivier Laurent <olt@odoo.com> | 2015-09-09 13:36:33 +0200 |
| commit | d0faf2815428293c16e47ddd3a4ca2e512c730c4 (patch) | |
| tree | bb8458cd5af94eb120457ca440785225899e5b1e /addons/analytic/models/analytic.py | |
| parent | 4f09d136d08dddd924f2cac173cf12a114c58ccf (diff) | |
[FIX] analytic: methods used in default attribute should return a RecordSet
If a method used as a default returns an id instead of a RecordSet,
it could fail in 'convert_to_write' (Many2One field) because it will try
to return "value.id". If "value" is an integer, it fails.
Also changed the method to a lambda expression and removed the
'_default_user' method because it's not used anywhere.
Diffstat (limited to 'addons/analytic/models/analytic.py')
| -rw-r--r-- | addons/analytic/models/analytic.py | 10 |
1 files changed, 1 insertions, 9 deletions
diff --git a/addons/analytic/models/analytic.py b/addons/analytic/models/analytic.py index 35ec3a0992b..1ea482e1601 100644 --- a/addons/analytic/models/analytic.py +++ b/addons/analytic/models/analytic.py @@ -41,14 +41,6 @@ class account_analytic_account(models.Model): account.credit = data_credit.get(account.id, 0.0) account.balance = account.credit - account.debit - @api.model - def _default_company(self): - return self.env.user.company_id.id - - @api.model - def _default_user(self): - return self.env.user.id - name = fields.Char(string='Analytic Account', index=True, required=True, track_visibility='onchange') code = fields.Char(string='Reference', index=True, track_visibility='onchange') account_type = fields.Selection([ @@ -58,7 +50,7 @@ class account_analytic_account(models.Model): tag_ids = fields.Many2many('account.analytic.tag', 'account_analytic_account_tag_rel', 'account_id', 'tag_id', string='Tags', copy=True) line_ids = fields.One2many('account.analytic.line', 'account_id', string="Analytic Lines") - company_id = fields.Many2one('res.company', string='Company', required=True, default=_default_company) + company_id = fields.Many2one('res.company', string='Company', required=True, default=lambda self: self.env.user.company_id) partner_id = fields.Many2one('res.partner', string='Customer') balance = fields.Monetary(compute='_compute_debit_credit_balance', string='Balance') |
