Steps to reproduce: - create two products - create two analytic accounts - create two new analytic rules by assigning an account to a product - Create a new PO and select on of the product - On the same line, change the product to the other one Issue: - The analytic account won't be updated Cause: Bypass of the `account_analytic_id` whenever there is already on defined Solution: For the `Sale` fix, I added the `line.state == 'draft'`. The reason? Because the compute is triggered after confirmation of the order due to: https://github.com/odoo/odoo/blob/14.0/addons/sale/models/sale.py#L931-L935 Therefore, the compute won't also be triggered after confirmation of the SO. opw-2948950 closes odoo/odoo#99858 X-original-commit: 61604e18128c1cfd0e6d4e510852f780491d6e4e Signed-off-by: William André (wan) <wan@odoo.com>