odoo/odoo#228707

Created by fw-bot
Merged at 4efe975ec407f66111395ded81f65ec7d2cd69c1

Statuses:

label
odoo-dev:saas-18.2-18.0-fix_so_project_update_with_removed_analytic_account-459732-fw
head
4ce1f8273a27f4091295d57f7c678d52a4708496
merged
8 months ago by Fun Services, Xavier Bol (xbo)
odoo/odoo
18.0 #224895
saas-18.2 #228707
saas-18.3 #228732
saas-18.4 #228757
19.0 #228788
saas-19.1
saas-19.2
saas-19.3
master #228988

[FIX] sale_project: Clear deleted analytic accounts from so lines

Issue:

In a sale order, if any of the so lines contains the ID of a deleted analytic account in its analytic_distribution field, then updating the project_id field is impossible as it raises an error.

Cause

This is caused because _compute_analytic_distribution() tries to retrieve 'root_plan_id' from all ids without checking if records exists.

Fix

This commit add an exists() check on analytic.accounts retrieved from analytic_distribution field and clear the non-existing records ids from the field.

Steps to reproduce


Current behavior before PR: When creating a sale order and binding it to a project with an analytic account, then deleting the analytic account, the field "Project" on the sale order can't be updated anymore.

Desired behavior after PR is merged: When creating a sale order and binding it to a project with an analytic account, then deleting the analytic account, the field "Project" on the sale order can be updated.


I confirm I have signed the CLA and read the PR guidelines at www.odoo.com/submit-pr

Forward-Port-Of: #224895