From 406ec9dcdf5e75e3803ca250b34ec372bcf3a3a0 Mon Sep 17 00:00:00 2001 From: "Andrea Grazioso (agr-odoo)" Date: Wed, 8 Mar 2023 10:49:49 +0000 Subject: [PATCH] [FIX] account: analytic plan match Settings>Accounting, activate analytics Create an Analytic Plan: - Default Applicability: Optional - Add 1 applicability line: - Domain: Vendor Bill - Product Category: All / Saleable / Office Furniture - Applicability: Mandatory Create a vendor bill, fill partner, billdate and create a line without product Save and Confirm Action will be blocked with message: "One or more lines require a 100% analytic distribution." This should not occur as the mandatory applicability should not match the bill opw-3189829 closes odoo/odoo#117162 X-original-commit: c4f90cf7b116fbec8516659475c4e1160a00b2f1 Signed-off-by: Laurent Smet Signed-off-by: Grazioso Andrea (agr) --- addons/account/models/account_analytic_plan.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/addons/account/models/account_analytic_plan.py b/addons/account/models/account_analytic_plan.py index 54079549439..1f8e3613c9b 100644 --- a/addons/account/models/account_analytic_plan.py +++ b/addons/account/models/account_analytic_plan.py @@ -36,13 +36,13 @@ class AccountAnalyticApplicability(models.Model): return -1 product = self.env['product.product'].browse(kwargs.get('product', None)) account = self.env['account.account'].browse(kwargs.get('account', None)) - if account and self.account_prefix: - if account.code.startswith(self.account_prefix): + if self.account_prefix: + if account and account.code.startswith(self.account_prefix): score += 1 else: return -1 - if product and self.product_categ_id: - if product.categ_id == self.product_categ_id: + if self.product_categ_id: + if product and product.categ_id == self.product_categ_id: score += 1 else: return -1