From b2fb17f3c4ef11e6dda2db3615fb571fda47f771 Mon Sep 17 00:00:00 2001 From: Goffin Simon Date: Wed, 19 Jul 2017 11:21:34 +0200 Subject: [PATCH] [FIX] hr_expense: Domain on field account_id in model hr.expense It was possible to set a payable account for an expense. So it raised a UserError when reconciling the lines in function expense_post_payment because two different accounts were used as payable account. A expense account is expected as account for an expense. opw:752695 --- addons/hr_expense/i18n/hr_expense.pot | 5 +++++ addons/hr_expense/models/hr_expense.py | 3 ++- addons/hr_expense/views/hr_expense_views.xml | 2 +- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/addons/hr_expense/i18n/hr_expense.pot b/addons/hr_expense/i18n/hr_expense.pot index 7b9e4ea5604..db423e344e7 100644 --- a/addons/hr_expense/i18n/hr_expense.pot +++ b/addons/hr_expense/i18n/hr_expense.pot @@ -154,6 +154,11 @@ msgstr "" msgid "Analytic Account" msgstr "" +#. module: hr_expense +#: model:ir.model.fields,help:hr_expense.field_hr_expense_account_id +msgid "An expense account is expected" +msgstr "" + #. module: hr_expense #: model:ir.ui.view,arch_db:hr_expense.view_hr_expense_configuration msgid "Apply" diff --git a/addons/hr_expense/models/hr_expense.py b/addons/hr_expense/models/hr_expense.py index e9a3409a322..6065f1a0ec3 100644 --- a/addons/hr_expense/models/hr_expense.py +++ b/addons/hr_expense/models/hr_expense.py @@ -30,7 +30,8 @@ class HrExpense(models.Model): company_id = fields.Many2one('res.company', string='Company', readonly=True, states={'draft': [('readonly', False)], 'refused': [('readonly', False)]}, default=lambda self: self.env.user.company_id) currency_id = fields.Many2one('res.currency', string='Currency', readonly=True, states={'draft': [('readonly', False)], 'refused': [('readonly', False)]}, default=lambda self: self.env.user.company_id.currency_id) analytic_account_id = fields.Many2one('account.analytic.account', string='Analytic Account', states={'post': [('readonly', True)], 'done': [('readonly', True)]}, oldname='analytic_account') - account_id = fields.Many2one('account.account', string='Account', states={'post': [('readonly', True)], 'done': [('readonly', True)]}, default=lambda self: self.env['ir.property'].get('property_account_expense_categ_id', 'product.category')) + account_id = fields.Many2one('account.account', string='Account', states={'post': [('readonly', True)], 'done': [('readonly', True)]}, default=lambda self: self.env['ir.property'].get('property_account_expense_categ_id', 'product.category'), + help="An expense account is expected") description = fields.Text() payment_mode = fields.Selection([("own_account", "Employee (to reimburse)"), ("company_account", "Company")], default='own_account', states={'done': [('readonly', True)], 'post': [('readonly', True)]}, string="Payment By") attachment_number = fields.Integer(compute='_compute_attachment_number', string='Number of Attachments') diff --git a/addons/hr_expense/views/hr_expense_views.xml b/addons/hr_expense/views/hr_expense_views.xml index 4c9f37f1f0d..8a9e2b220ea 100644 --- a/addons/hr_expense/views/hr_expense_views.xml +++ b/addons/hr_expense/views/hr_expense_views.xml @@ -60,7 +60,7 @@ - +