[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) <bib@odoo.com>
Signed-off-by: Anh Thao Pham (pta) <pta@odoo.com>
This commit is contained in:
Anh Thao Pham (pta)
2024-04-02 15:40:29 +00:00
parent e600f52553
commit bba3eee1ff
+5 -1
View File
@@ -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: {