[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
This commit is contained in:
Goffin Simon
2017-07-19 13:51:37 +02:00
parent c0dbbe6320
commit b2fb17f3c4
3 changed files with 8 additions and 2 deletions
+5
View File
@@ -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"
+2 -1
View File
@@ -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')
+1 -1
View File
@@ -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"/>