From bba3eee1ff2ef8627968bed7851bfd174672900c Mon Sep 17 00:00:00 2001 From: "Anh Thao Pham (pta)" Date: Mon, 25 Mar 2024 07:58:32 +0000 Subject: [PATCH] [FIX] hr_expense: validate analytic when approving expense sheet from list view Steps to reproduce: - Install Accouting and Expenses - Activate "Analytic Accounting" in Accounting settings - Go to "Accounting / Configuration / Analytic Accounting / Analytic Plans" - Create an analytic plan with the following line: * Domain: Expense * Applicability: Mandatory - Create an analytic account from the plan via "Analytic Accounts" smart button - Create an expense without analytic - Create a report from it - Submit it to manager - Try to approve it => An expected Validation Error will raise: "One or more lines require a 100% analytic distribution." - Go to "Expenses / Expense Reports" (list view) - Select the created expense report - Try to approve it Issue: The report will be approved even if there is no analytic configured on it. Cause: "validate_analytic" option is not passed in the context when approving the report from list view as it is done in form view. opw-3806787 closes odoo/odoo#160143 X-original-commit: f25a1192454b988f90d454ad9a2706de1415a2ee Signed-off-by: Brice Bartoletti (bib) Signed-off-by: Anh Thao Pham (pta) --- addons/hr_expense/static/src/views/list.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/addons/hr_expense/static/src/views/list.js b/addons/hr_expense/static/src/views/list.js index 84ac47d980d..fb32960e111 100644 --- a/addons/hr_expense/static/src/views/list.js +++ b/addons/hr_expense/static/src/views/list.js @@ -56,7 +56,11 @@ export class ExpenseListController extends ExpenseDocumentUpload(ListController) const records = this.model.root.selection; const recordIds = records.map((a) => a.resId); const model = this.model.config.resModel; - const res = await this.orm.call(model, action, [recordIds]); + const context = {}; + if (action === 'action_approve_expense_sheets') { + context['validate_analytic'] = true; + } + const res = await this.orm.call(model, action, [recordIds], {context: context}); if (res) { await this.actionService.doAction(res, { additionalContext: {