diff options
| author | Goffin Simon <sig@odoo.com> | 2017-07-19 11:21:34 +0200 |
|---|---|---|
| committer | Goffin Simon <sig@odoo.com> | 2017-07-19 13:51:37 +0200 |
| commit | b2fb17f3c4ef11e6dda2db3615fb571fda47f771 (patch) | |
| tree | c36b8449e7f3f67e0d6b276c4c130130468e08db | |
| parent | c0dbbe63201fbf2002b048e3edde583e30ed0406 (diff) | |
[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
| -rw-r--r-- | addons/hr_expense/i18n/hr_expense.pot | 5 | ||||
| -rw-r--r-- | addons/hr_expense/models/hr_expense.py | 3 | ||||
| -rw-r--r-- | 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 @@ -155,6 +155,11 @@ 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" msgstr "" 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 @@ </group><group> <field name="reference"/> <field name="date"/> - <field name="account_id"/> + <field name="account_id" domain="[('internal_type', '=', 'other')]"/> <field name="employee_id"/> <field name="sheet_id" invisible="1"/> <field name="currency_id" groups="base.group_multi_currency"/> |
