summaryrefslogtreecommitdiff
path: root/addons/analytic/models
diff options
context:
space:
mode:
authorNicolas Martinelli <nim@odoo.com>2018-04-13 10:47:11 +0200
committerChristophe Monniez <moc@odoo.com>2018-04-13 10:47:11 +0200
commit3b158b65c118d24b32aedc27c50e9dd726b04280 (patch)
treec9417bf418c0743848c4c3d579fdcf7c4e7ea0fe /addons/analytic/models
parent2f16d6bfe397b7d0c8ff31bfe7eb0c326f2740e8 (diff)
[FIX] analytic, hr_timesheet: recompute order
When creating a timesheet, several fields need to be recomputed: - `currency_id` - `group_id` - `department_id` - `is_timesheet` - `validated` When `validated` is computed before the other fields, the recomputation will lead to an `AccessError` because of the rule `hr_timesheet.timesheet_line_rule_user`. Since the test `test_timesheet_validation_user` expects an `AccessError`, the test succeeds. However, from time to time, `validated` is computed last => the `AccessError` is not raised. Actually, a `ValidationError` should be raised in this case (from the `create` override in `timesheet_grid`). This commit is a cherry-pick of 802339c12d1984d1f29e574378cd8df2471ab098 and dcca2e8b9da685c13ba3fe8d3196b8e83fb429ba
Diffstat (limited to 'addons/analytic/models')
-rw-r--r--addons/analytic/models/analytic_account.py4
1 files changed, 2 insertions, 2 deletions
diff --git a/addons/analytic/models/analytic_account.py b/addons/analytic/models/analytic_account.py
index d6ee2b69275..fbf7951aa4e 100644
--- a/addons/analytic/models/analytic_account.py
+++ b/addons/analytic/models/analytic_account.py
@@ -154,8 +154,8 @@ class AccountAnalyticLine(models.Model):
user_id = fields.Many2one('res.users', string='User', default=_default_user)
tag_ids = fields.Many2many('account.analytic.tag', 'account_analytic_line_tag_rel', 'line_id', 'tag_id', string='Tags', copy=True)
company_id = fields.Many2one('res.company', string='Company', required=True, readonly=True, default=lambda self: self.env.user.company_id)
- currency_id = fields.Many2one(related="company_id.currency_id", string="Currency", readonly=True, store=True)
- group_id = fields.Many2one('account.analytic.group', related='account_id.group_id', store=True, readonly=True)
+ currency_id = fields.Many2one(related="company_id.currency_id", string="Currency", readonly=True, store=True, compute_sudo=True)
+ group_id = fields.Many2one('account.analytic.group', related='account_id.group_id', store=True, readonly=True, compute_sudo=True)
@api.multi
@api.constrains('company_id', 'account_id')