From 08776c1d39db5df419ced0f0fc192e725f7187ea Mon Sep 17 00:00:00 2001 From: hupo-odoo Date: Thu, 23 Feb 2023 12:32:30 +0000 Subject: [PATCH] [FIX] sale_project: analytic default plan issue: When creating a sale order, with a service that involves the creation of a project, with analytic accounting activated, the default analytic account is not the default one set in the settings of the Project app. Steps to reproduce the issue : - activate analytic accounting in the Accounting app. - in the settings of the Project app, set the default analytic plan to any value but the first one. - create a product in the Sale app, with a product type 'Service', that involves the creation of a 'Project'. - create a sale order with the product - go in the analytic accounting menu in Accounting app -> the analytic plan is not the one set by default in the settings of the Project app. closes odoo/odoo#114302 Task: 3169483 X-original-commit: e801b3fa1bbc31713375cc669c6d47b32b175f53 Signed-off-by: Quentin De Paoli Signed-off-by: hupo-odoo --- addons/sale_project/models/sale_order.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/addons/sale_project/models/sale_order.py b/addons/sale_project/models/sale_order.py index 321db740f82..c1e3e137912 100644 --- a/addons/sale_project/models/sale_order.py +++ b/addons/sale_project/models/sale_order.py @@ -163,3 +163,8 @@ class SaleOrder(models.Model): if 'state' in values and values['state'] == 'cancel': self.project_id.sudo().sale_line_id = False return super(SaleOrder, self).write(values) + + def _prepare_analytic_account_data(self, prefix=None): + result = super(SaleOrder, self)._prepare_analytic_account_data(prefix=prefix) + result['plan_id'] = self.company_id.analytic_plan_id.id or result['plan_id'] + return result