[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 <las@odoo.com>
Signed-off-by: Grazioso Andrea (agr) <agr@odoo.com>
This commit is contained in:
Andrea Grazioso (agr-odoo)
2023-03-30 16:23:01 +02:00
parent 53d0b30c53
commit 406ec9dcdf
@@ -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