Skip to content

Commit

Permalink
[FIX] sale_commission_partial_settlement: partial_commission computation
Browse files Browse the repository at this point in the history
  • Loading branch information
aleuffre committed Dec 10, 2024
1 parent 51d6489 commit 62bea39
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 5 deletions.
2 changes: 1 addition & 1 deletion sale_commission_partial_settlement/__manifest__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Copyright 2023 Nextev
{
"name": "Sales commissions based on paid amount",
"version": "14.0.1.2.0",
"version": "14.0.1.2.1",
"author": "Nextev Srl," "Ooops," "Odoo Community Association (OCA)",
"maintainers": ["aleuffre", "renda-dev", "PicchiSeba"],
"category": "Sales Management",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
from openupgradelib import openupgrade


def recompute_partial_commission_settled(env):
"""
Recompute field "partial_commission_settled"
of model "account.partial.reconcile"
"""
env["account.partial.reconcile"].search([])._compute_partial_commission_settled()


@openupgrade.migrate()
def migrate(env, version):
recompute_partial_commission_settled(env)
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,10 @@ def _compute_partial_settled(self):
rec.partial_settled = sum(
ailap.amount
for ailap in rec.invoice_line_agent_partial_ids
if ailap.mapped("agent_line.settlement_id")[:1].state != "cancel"
if any(
settlement.state != "cancel"
for settlement in ailap.mapped("agent_line.settlement_id")
)
)

@api.depends(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@ class AccountPartialReconcile(models.Model):
)
def _compute_partial_commission_settled(self):
for rec in self:
rec.partial_commission_settled = bool(
rec.account_invoice_line_agent_partial_ids.filtered(
lambda x: x.mapped("agent_line.settlement_id")[:1].state != "cancel"
rec.partial_commission_settled = any(
settlement.state != "cancel"
for settlement in rec.mapped(
"account_invoice_line_agent_partial_ids.agent_line.settlement_id"
)
)

0 comments on commit 62bea39

Please sign in to comment.