odoo/odoo#203194

Created by fw-bot
Merged at 9b173078a74f3b50ed90eb62fb15208e74776473

Statuses:

label
odoo-dev:18.0-18.0-fix-mandatory-analytic-plans-srma-425073-fw
head
a7ed7cf4479ba9b80875fc7f826a323ed34a1935
merged
7 months ago by Accounting, Maira Salazar
odoo/odoo
16.0 #201560
17.0 #203006
saas-17.4 #203153
18.0 #203194
saas-18.1 #203338
saas-18.2 #203447
saas-18.3
saas-18.4
19.0
master #203480

[FW][IMP] account: validate mandatory analytic plans when batch posting

When we have an Analytic Plan being Mandatory, confirming an invoice from the form view, if it has a line without an Analytic distribution, correctly raises a ValidationError.
Confirming invoices from the list view does not raise the same error, yet it should.

To replicate:
1. Activate Analytic accounting:
a. Install accountant
b. In Settings, activate Analytic Accounting
c. Create an Analytic plan (with an Analytic account associated)
2. Set its default applicability to mandatory
3. Create two invoices, remove the analytic distribution from one of the lines in one invoice.
4. In the invoices list view, select both newly created invoices, click on Actions > Confirm Entries
5. Click Confirm
6. The invoices were posted, even though they have no analytic distributions.

Ticket link
opw-4603919

Forward-Port-Of: #203153
Forward-Port-Of: #201560