Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[14.0][FIX] sale_commission_partial_settlement: partial_commission computation #585

Merged
merged 1 commit into from
Dec 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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"
)
)
Loading