[IMP] hr_expense,project_sale_expense: Clarifying user error when partner is missing

When the partner is missing, the error message is not clear enough.
This commit adds a new error message to clarify the issue.

Task ID: 3438559

closes odoo/odoo#132029

X-original-commit: 5be853ebb6da19a4f0a147944995583e234bf1b9
Related: odoo/enterprise#45779
Signed-off-by: Laurent Smet (las) <las@odoo.com>
Signed-off-by: Naceur Amine Saddem (sana) <sana@odoo.com>
This commit is contained in:
SaddemAmine
2023-08-16 17:47:45 +02:00
parent 92ce339ec0
commit 5bd4120928
3 changed files with 6 additions and 2 deletions
+3
View File
@@ -1446,6 +1446,9 @@ class HrExpenseSheet(models.Model):
if any(not sheet.journal_id for sheet in self):
raise UserError(_("Specify expense journal to generate accounting entries."))
if not self.employee_id.work_email:
raise UserError(_("The work email of the employee is required to post the expense report. Please add it on the employee form."))
def _do_submit(self):
self.write({'approval_state': 'submit'})
self.sudo().activity_update()
+1 -1
View File
@@ -192,7 +192,7 @@
<field name="amount_tax"
attrs="{'invisible': [('product_has_tax', '=', False)]}"/>
</div>
<field name="employee_id" groups="hr_expense.group_hr_expense_team_approver" context="{'default_company_id': company_id}" widget="many2one_avatar_user"/>
<field name="employee_id" groups="hr_expense.group_hr_expense_team_approver" context="{'default_company_id': company_id}" widget="many2one_avatar_user" options="{'no_create': True}" />
<label id="lo" for="payment_mode" attrs="{'invisible': [('product_has_cost', '=', True)]}"/>
<div id="payment_mode" attrs="{'invisible': [('product_has_cost', '=', True)]}">
<field name="payment_mode" widget="radio"/>
@@ -24,7 +24,8 @@ class TestProjectSaleExpenseProfitability(TestProjectProfitabilityCommon, TestPr
foreign_employee = self.env['hr.employee'].create({
'name': 'foreign_employee',
'company_id': foreign_company.id,
'work_contact_id': foreign_partner.id
'work_contact_id': foreign_partner.id,
'work_email': 'email@email',
})
expense = self.env['hr.expense'].create({