From ab8191badf608e5707a32299e47b1d4de2dee621 Mon Sep 17 00:00:00 2001 From: David Alonso Date: Wed, 11 Sep 2024 20:01:21 +0200 Subject: [PATCH] [MIG] sale_commission_partial_settlement: Migration to 16.0 --- sale_commission_partial_settlement/README.rst | 10 +- .../__manifest__.py | 4 +- .../migrations/14.0.1.0.1/post-migrate.py | 11 - .../models/__init__.py | 7 +- ..._move.py => account_invoice_line_agent.py} | 45 +--- .../account_invoice_line_agent_partial.py | 22 ++ .../{sale_commission.py => commission.py} | 4 +- ...ement.py => commission_settlement_line.py} | 6 +- .../static/description/index.html | 17 +- .../tests/common.py | 183 +++++++++++++++ .../tests/test_partial_settlement.py | 208 +----------------- ...ommission_view.xml => commission_view.xml} | 8 +- .../wizard/__init__.py | 2 +- ...rd_settle.py => commission_make_settle.py} | 29 ++- .../models/sale.py | 2 +- 15 files changed, 267 insertions(+), 291 deletions(-) delete mode 100644 sale_commission_partial_settlement/migrations/14.0.1.0.1/post-migrate.py rename sale_commission_partial_settlement/models/{account_move.py => account_invoice_line_agent.py} (71%) create mode 100644 sale_commission_partial_settlement/models/account_invoice_line_agent_partial.py rename sale_commission_partial_settlement/models/{sale_commission.py => commission.py} (81%) rename sale_commission_partial_settlement/models/{settlement.py => commission_settlement_line.py} (81%) create mode 100644 sale_commission_partial_settlement/tests/common.py rename sale_commission_partial_settlement/views/{sale_commission_view.xml => commission_view.xml} (56%) rename sale_commission_partial_settlement/wizard/{wizard_settle.py => commission_make_settle.py} (79%) diff --git a/sale_commission_partial_settlement/README.rst b/sale_commission_partial_settlement/README.rst index 984415fd0..4cd76a036 100644 --- a/sale_commission_partial_settlement/README.rst +++ b/sale_commission_partial_settlement/README.rst @@ -17,13 +17,13 @@ Sales commissions based on paid amount :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html :alt: License: AGPL-3 .. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fcommission-lightgray.png?logo=github - :target: https://github.com/OCA/commission/tree/14.0/sale_commission_partial_settlement + :target: https://github.com/OCA/commission/tree/16.0/sale_commission_partial_settlement :alt: OCA/commission .. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png - :target: https://translation.odoo-community.org/projects/commission-14-0/commission-14-0-sale_commission_partial_settlement + :target: https://translation.odoo-community.org/projects/commission-16-0/commission-16-0-sale_commission_partial_settlement :alt: Translate me on Weblate .. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png - :target: https://runboat.odoo-community.org/builds?repo=OCA/commission&target_branch=14.0 + :target: https://runboat.odoo-community.org/builds?repo=OCA/commission&target_branch=16.0 :alt: Try me on Runboat |badge1| |badge2| |badge3| |badge4| |badge5| @@ -50,7 +50,7 @@ Bug Tracker Bugs are tracked on `GitHub Issues `_. In case of trouble, please check there if your issue has already been reported. If you spotted it first, help us to smash it by providing a detailed and welcomed -`feedback `_. +`feedback `_. Do not contact contributors directly about support or help with technical issues. @@ -105,6 +105,6 @@ Current `maintainers `__: |maintainer-aleuffre| |maintainer-renda-dev| |maintainer-PicchiSeba| -This module is part of the `OCA/commission `_ project on GitHub. +This module is part of the `OCA/commission `_ project on GitHub. You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/sale_commission_partial_settlement/__manifest__.py b/sale_commission_partial_settlement/__manifest__.py index 1b98f3e68..019f8ea1e 100644 --- a/sale_commission_partial_settlement/__manifest__.py +++ b/sale_commission_partial_settlement/__manifest__.py @@ -1,7 +1,7 @@ # Copyright 2023 Nextev { "name": "Sales commissions based on paid amount", - "version": "14.0.1.0.1", + "version": "16.0.1.0.0", "author": "Nextev Srl," "Ooops," "Odoo Community Association (OCA)", "maintainers": ["aleuffre", "renda-dev", "PicchiSeba"], "category": "Sales Management", @@ -10,7 +10,7 @@ "website": "https://github.com/OCA/commission", "data": [ "security/ir.model.access.csv", - "views/sale_commission_view.xml", + "views/commission_view.xml", ], "installable": True, } diff --git a/sale_commission_partial_settlement/migrations/14.0.1.0.1/post-migrate.py b/sale_commission_partial_settlement/migrations/14.0.1.0.1/post-migrate.py deleted file mode 100644 index 626eae3f9..000000000 --- a/sale_commission_partial_settlement/migrations/14.0.1.0.1/post-migrate.py +++ /dev/null @@ -1,11 +0,0 @@ -from openupgradelib import openupgrade - - -@openupgrade.migrate() -def migrate(env, version): - env["account.invoice.line.agent"].search( - [ - ("settled", "=", True), - ("commission_id.payment_amount_type", "=", "paid"), - ] - )._compute_settled() diff --git a/sale_commission_partial_settlement/models/__init__.py b/sale_commission_partial_settlement/models/__init__.py index 4e17db438..d98e158fb 100644 --- a/sale_commission_partial_settlement/models/__init__.py +++ b/sale_commission_partial_settlement/models/__init__.py @@ -1,4 +1,5 @@ -from . import sale_commission -from . import account_move +from . import commission +from . import account_invoice_line_agent +from . import account_invoice_line_agent_partial from . import account_partial_reconcile -from . import settlement +from . import commission_settlement_line diff --git a/sale_commission_partial_settlement/models/account_move.py b/sale_commission_partial_settlement/models/account_invoice_line_agent.py similarity index 71% rename from sale_commission_partial_settlement/models/account_move.py rename to sale_commission_partial_settlement/models/account_invoice_line_agent.py index a402c5ed3..6f1562eb7 100644 --- a/sale_commission_partial_settlement/models/account_move.py +++ b/sale_commission_partial_settlement/models/account_invoice_line_agent.py @@ -14,10 +14,10 @@ def _compute_settled(self): lambda x: x.commission_id.payment_amount_type != "paid" ) for line in self - filtered_lines: - if not line.mapped("agent_line.settlement_id"): + if not line.settlement_line_ids: line.settled = False - super(AccountInvoiceLineAgent, filtered_lines)._compute_settled() + return super(AccountInvoiceLineAgent, filtered_lines)._compute_settled() def _partial_commissions(self, date_payment_to): """ @@ -33,11 +33,12 @@ def _partial_commissions(self, date_payment_to): lines_to_update = {} for line in self: line_total_amount = line.amount + reconciled_partials, _ = line.invoice_id._get_reconciled_invoices_partials() for ( partial, amount, counterpart_line, - ) in line.invoice_id._get_reconciled_invoices_partials(): + ) in reconciled_partials: if partial.partial_commission_settled: continue elif date_payment_to and date_payment_to < counterpart_line.date: @@ -51,11 +52,7 @@ def _partial_commissions(self, date_payment_to): partial_payment_remaining[partial.id] = {"remaining_amount": amount} if line.object_id.price_total <= payment_amount: partial_lines_to_settle.append( - { - "invoice_line_agent_id": line.id, - "currency_id": line.currency_id.id, - "amount": line_total_amount, - } + self._partial_agent_line_values(line, line_total_amount) ) lines_to_update[line.id] = { "partial_settled": line_total_amount, @@ -71,11 +68,7 @@ def _partial_commissions(self, date_payment_to): line.invoice_id.commission_total * paid_in_proportion ) partial_lines_to_settle.append( - { - "invoice_line_agent_id": line.id, - "currency_id": line.currency_id.id, - "amount": partial_commission, - } + self._partial_agent_line_values(line, partial_commission) ) if line.id in lines_to_update: lines_to_update[line.id]["partial_settled"] += partial_commission @@ -91,23 +84,9 @@ def _partial_commissions(self, date_payment_to): ) return partial_agent_lines, lines_to_update - -class AccountInvoiceLineAgentPartial(models.Model): - _name = "account.invoice.line.agent.partial" - _description = "Partial agent commissions" - - invoice_line_agent_id = fields.Many2one("account.invoice.line.agent", required=True) - agent_line = fields.Many2many( - comodel_name="sale.commission.settlement.line", - relation="settlement_agent_line_partial_rel", - column1="agent_line_partial_id", - column2="settlement_id", - copy=False, - ) - amount = fields.Monetary( - string="Commission Amount", - ) - currency_id = fields.Many2one( - related="invoice_line_agent_id.currency_id", - ) - settled = fields.Boolean() + def _partial_agent_line_values(self, line, amount): + return { + "invoice_line_agent_id": line.id, + "currency_id": line.currency_id.id, + "amount": amount, + } diff --git a/sale_commission_partial_settlement/models/account_invoice_line_agent_partial.py b/sale_commission_partial_settlement/models/account_invoice_line_agent_partial.py new file mode 100644 index 000000000..f6f608dea --- /dev/null +++ b/sale_commission_partial_settlement/models/account_invoice_line_agent_partial.py @@ -0,0 +1,22 @@ +from odoo import fields, models + + +class AccountInvoiceLineAgentPartial(models.Model): + _name = "account.invoice.line.agent.partial" + _description = "Partial agent commissions" + + invoice_line_agent_id = fields.Many2one("account.invoice.line.agent", required=True) + agent_line = fields.Many2many( + comodel_name="commission.settlement.line", + relation="settlement_agent_line_partial_rel", + column1="agent_line_partial_id", + column2="settlement_id", + copy=False, + ) + amount = fields.Monetary( + string="Commission Amount", + ) + currency_id = fields.Many2one( + related="invoice_line_agent_id.currency_id", + ) + settled = fields.Boolean() diff --git a/sale_commission_partial_settlement/models/sale_commission.py b/sale_commission_partial_settlement/models/commission.py similarity index 81% rename from sale_commission_partial_settlement/models/sale_commission.py rename to sale_commission_partial_settlement/models/commission.py index 68f03aea9..dcb090762 100644 --- a/sale_commission_partial_settlement/models/sale_commission.py +++ b/sale_commission_partial_settlement/models/commission.py @@ -3,8 +3,8 @@ from odoo import fields, models -class SaleCommission(models.Model): - _inherit = "sale.commission" +class Commission(models.Model): + _inherit = "commission" payment_amount_type = fields.Selection( [("full", "Full amount"), ("paid", "Paid amount")], diff --git a/sale_commission_partial_settlement/models/settlement.py b/sale_commission_partial_settlement/models/commission_settlement_line.py similarity index 81% rename from sale_commission_partial_settlement/models/settlement.py rename to sale_commission_partial_settlement/models/commission_settlement_line.py index f25ba11e0..63dba3971 100644 --- a/sale_commission_partial_settlement/models/settlement.py +++ b/sale_commission_partial_settlement/models/commission_settlement_line.py @@ -1,8 +1,8 @@ from odoo import api, fields, models -class SettlementLine(models.Model): - _inherit = "sale.commission.settlement.line" +class CommissionSettlementLine(models.Model): + _inherit = "commission.settlement.line" agent_line_partial_ids = fields.Many2many( comodel_name="account.invoice.line.agent.partial", @@ -23,4 +23,4 @@ def _compute_settled_amount(self): if rec.commission_id.payment_amount_type == "paid": rec.settled_amount = rec.agent_line_partial_ids[:1].amount else: - rec.settled_amount = rec.agent_line[:1].amount + rec.settled_amount = rec.invoice_agent_line_id[:1].amount diff --git a/sale_commission_partial_settlement/static/description/index.html b/sale_commission_partial_settlement/static/description/index.html index 6bf4cbe3b..74000c070 100644 --- a/sale_commission_partial_settlement/static/description/index.html +++ b/sale_commission_partial_settlement/static/description/index.html @@ -8,11 +8,10 @@ /* :Author: David Goodger (goodger@python.org) -:Id: $Id: html4css1.css 9511 2024-01-13 09:50:07Z milde $ +:Id: $Id: html4css1.css 8954 2022-01-20 10:10:25Z milde $ :Copyright: This stylesheet has been placed in the public domain. Default cascading style sheet for the HTML output of Docutils. -Despite the name, some widely supported CSS2 features are used. See https://docutils.sourceforge.io/docs/howto/html-stylesheets.html for how to customize this style sheet. @@ -275,7 +274,7 @@ margin-left: 2em ; margin-right: 2em } -pre.code .ln { color: gray; } /* line numbers */ +pre.code .ln { color: grey; } /* line numbers */ pre.code, code { background-color: #eeeeee } pre.code .comment, code .comment { color: #5C6576 } pre.code .keyword, code .keyword { color: #3B0D06; font-weight: bold } @@ -301,7 +300,7 @@ span.pre { white-space: pre } -span.problematic, pre.problematic { +span.problematic { color: red } span.section-subtitle { @@ -369,7 +368,7 @@

Sales commissions based on paid amount

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !! source digest: sha256:72b8b9ff4225524c4105f059588ec2038649d39259909c6d43d8e7c4b62b06a2 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! --> -

Beta License: AGPL-3 OCA/commission Translate me on Weblate Try me on Runboat

+

Beta License: AGPL-3 OCA/commission Translate me on Weblate Try me on Runboat

This module allows to settle commissions based on paid amount.

Table of contents

@@ -398,7 +397,7 @@

Bug Tracker

Bugs are tracked on GitHub Issues. In case of trouble, please check there if your issue has already been reported. If you spotted it first, help us to smash it by providing a detailed and welcomed -feedback.

+feedback.

Do not contact contributors directly about support or help with technical issues.

@@ -439,15 +438,13 @@

Contributors

Maintainers

This module is maintained by the OCA.

- -Odoo Community Association - +Odoo Community Association

OCA, or the Odoo Community Association, is a nonprofit organization whose mission is to support the collaborative development of Odoo features and promote its widespread use.

Current maintainers:

aleuffre renda-dev PicchiSeba

-

This module is part of the OCA/commission project on GitHub.

+

This module is part of the OCA/commission project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

diff --git a/sale_commission_partial_settlement/tests/common.py b/sale_commission_partial_settlement/tests/common.py new file mode 100644 index 000000000..374984a01 --- /dev/null +++ b/sale_commission_partial_settlement/tests/common.py @@ -0,0 +1,183 @@ +from dateutil.relativedelta import relativedelta + +from odoo import fields +from odoo.tests.common import TransactionCase + + +class TestPartialSettlementCommon(TransactionCase): + @classmethod + def setUpClass(cls): + super().setUpClass() + cls.commission_model = cls.env["commission"] + cls.partial_commission_net_paid = cls.commission_model.create( + { + "name": "20% fixed commission (Net amount) - Payment Based - Partial", + "fix_qty": 20.0, + "invoice_state": "paid", + "amount_base_type": "net_amount", + "payment_amount_type": "paid", + } + ) + cls.company = cls.env.ref("base.main_company") + cls.res_partner_model = cls.env["res.partner"] + cls.partner = cls.env.ref("base.res_partner_2") + cls.partner.write({"agent": False}) + cls.sale_order_model = cls.env["sale.order"] + cls.advance_inv_model = cls.env["sale.advance.payment.inv"] + cls.settle_model = cls.env["commission.settlement"] + cls.make_settle_model = cls.env["commission.make.settle"] + cls.make_inv_model = cls.env["commission.make.invoice"] + cls.product = cls.env.ref("product.product_product_5") + cls.product.list_price = 5 # for testing specific commission section + cls.commission_product = cls.env["product.product"].create( + {"name": "Commission test product", "type": "service"} + ) + cls.product.write({"invoice_policy": "order"}) + cls.journal = cls.env["account.journal"].search( + [("type", "=", "purchase")], limit=1 + ) + cls.agent_monthly = cls.res_partner_model.create( + { + "name": "Test Agent - Monthly", + "agent": True, + "settlement": "monthly", + "lang": "en_US", + "commission_id": cls.partial_commission_net_paid.id, + } + ) + cls.income_account = cls.env["account.account"].search( + [ + ("company_id", "=", cls.company.id), + ("account_type", "=", "income"), + ], + limit=1, + ) + cls.commission_net_invoice = cls.commission_model.create( + { + "name": "10% fixed commission (Net amount) - Invoice Based", + "fix_qty": 10.0, + "amount_base_type": "net_amount", + } + ) + cls.agent_biweekly = cls.res_partner_model.create( + { + "name": "Test Agent - Bi-weekly", + "agent": True, + "settlement": "biweekly", + "lang": "en_US", + "commission_id": cls.commission_net_invoice.id, + } + ) + + def _create_multi_line_sale_order(self, agent, commission): + return self.sale_order_model.create( + { + "partner_id": self.partner.id, + "order_line": [ + ( + 0, + 0, + { + "name": self.product.name, + "product_id": self.product.id, + "product_uom_qty": 1.0, + "product_uom": self.ref("uom.product_uom_unit"), + "price_unit": self.product.lst_price, + "agent_ids": [ + ( + 0, + 0, + { + "agent_id": agent.id, + "commission_id": commission.id, + }, + ) + ], + }, + ), + ( + 0, + 0, + { + "name": self.product.name, + "product_id": self.product.id, + "product_uom_qty": 5.0, + "product_uom": self.ref("uom.product_uom_unit"), + "price_unit": self.product.lst_price, + "agent_ids": [ + ( + 0, + 0, + { + "agent_id": self.agent_monthly.id, + "commission_id": self.partial_commission_net_paid.id, + }, + ) + ], + }, + ), + ], + } + ) + + def _invoice_sale_order(self, sale_order): + old_invoices = sale_order.invoice_ids + wizard = self.advance_inv_model.create( + {"advance_payment_method": "delivered", "sale_order_ids": [sale_order.id]} + ) + wizard.with_context( + **{ + "active_model": "sale.order", + "active_ids": [sale_order.id], + "active_id": sale_order.id, + } + ).create_invoices() + invoice = sale_order.invoice_ids - old_invoices + return invoice + + def _settle_agent(self, agent=None, period=None, date=None): + vals = { + "date_to": ( + ( + fields.Datetime.from_string(fields.Datetime.now()) + + relativedelta(months=period) + ) + if period + else date + ), + "settlement_type": "sale_invoice", + } + if agent: + vals["agent_ids"] = [(4, agent.id)] + wizard = self.make_settle_model.create(vals) + wizard.action_settle() + + def register_payment( + self, + invoice, + payment_date, + amount=None, + payment_difference_handling="reconcile", + ): + payment_model = self.env["account.payment.register"] + invoice.action_post() + if not amount: + amount = invoice.amount_total + ctx = { + "active_model": "account.move", + "active_ids": [invoice.id], + } + return ( + payment_model.with_context(**ctx) + .create( + { + "payment_date": payment_date, + "amount": amount, + "journal_id": self.env["account.journal"] + .search([("type", "=", "bank")], limit=1) + .id, + "payment_difference_handling": payment_difference_handling, + } + ) + .action_create_payments() + ) diff --git a/sale_commission_partial_settlement/tests/test_partial_settlement.py b/sale_commission_partial_settlement/tests/test_partial_settlement.py index 66ba38ea4..54fa1448b 100644 --- a/sale_commission_partial_settlement/tests/test_partial_settlement.py +++ b/sale_commission_partial_settlement/tests/test_partial_settlement.py @@ -6,187 +6,11 @@ from dateutil.relativedelta import relativedelta from odoo import fields -from odoo.tests.common import SavepointCase +from .common import TestPartialSettlementCommon -class TestPartialSettlement(SavepointCase): - @classmethod - def setUpClass(cls): - super().setUpClass() - cls.commission_model = cls.env["sale.commission"] - cls.partial_commission_net_paid = cls.commission_model.create( - { - "name": "20% fixed commission (Net amount) - Payment Based - Partial", - "fix_qty": 20.0, - "invoice_state": "paid", - "amount_base_type": "net_amount", - "payment_amount_type": "paid", - } - ) - cls.company = cls.env.ref("base.main_company") - cls.res_partner_model = cls.env["res.partner"] - cls.partner = cls.env.ref("base.res_partner_2") - cls.partner.write({"agent": False}) - cls.sale_order_model = cls.env["sale.order"] - cls.advance_inv_model = cls.env["sale.advance.payment.inv"] - cls.settle_model = cls.env["sale.commission.settlement"] - cls.make_settle_model = cls.env["sale.commission.make.settle"] - cls.make_inv_model = cls.env["sale.commission.make.invoice"] - cls.product = cls.env.ref("product.product_product_5") - cls.product.list_price = 5 # for testing specific commission section - cls.commission_product = cls.env["product.product"].create( - {"name": "Commission test product", "type": "service"} - ) - cls.product.write({"invoice_policy": "order"}) - cls.journal = cls.env["account.journal"].search( - [("type", "=", "purchase")], limit=1 - ) - cls.agent_monthly = cls.res_partner_model.create( - { - "name": "Test Agent - Monthly", - "agent": True, - "settlement": "monthly", - "lang": "en_US", - "commission_id": cls.partial_commission_net_paid.id, - } - ) - cls.income_account = cls.env["account.account"].search( - [ - ("company_id", "=", cls.company.id), - ("user_type_id.name", "=", "Income"), - ], - limit=1, - ) - cls.commission_net_invoice = cls.commission_model.create( - { - "name": "10% fixed commission (Net amount) - Invoice Based", - "fix_qty": 10.0, - "amount_base_type": "net_amount", - } - ) - cls.agent_biweekly = cls.res_partner_model.create( - { - "name": "Test Agent - Bi-weekly", - "agent": True, - "settlement": "biweekly", - "lang": "en_US", - "commission_id": cls.commission_net_invoice.id, - } - ) - - def _create_multi_line_sale_order(self, agent, commission): - return self.sale_order_model.create( - { - "partner_id": self.partner.id, - "order_line": [ - ( - 0, - 0, - { - "name": self.product.name, - "product_id": self.product.id, - "product_uom_qty": 1.0, - "product_uom": self.ref("uom.product_uom_unit"), - "price_unit": self.product.lst_price, - "agent_ids": [ - ( - 0, - 0, - { - "agent_id": agent.id, - "commission_id": commission.id, - }, - ) - ], - }, - ), - ( - 0, - 0, - { - "name": self.product.name, - "product_id": self.product.id, - "product_uom_qty": 5.0, - "product_uom": self.ref("uom.product_uom_unit"), - "price_unit": self.product.lst_price, - "agent_ids": [ - ( - 0, - 0, - { - "agent_id": self.agent_monthly.id, - "commission_id": self.partial_commission_net_paid.id, - }, - ) - ], - }, - ), - ], - } - ) - - def _invoice_sale_order(self, sale_order, date=None): - old_invoices = sale_order.invoice_ids - wizard = self.advance_inv_model.create({"advance_payment_method": "delivered"}) - wizard.with_context( - { - "active_model": "sale.order", - "active_ids": [sale_order.id], - "active_id": sale_order.id, - } - ).create_invoices() - invoice = sale_order.invoice_ids - old_invoices - invoice.flush() - return invoice - - def _settle_agent(self, agent=None, period=None, date=None, date_payment_to=None): - vals = { - "date_to": ( - fields.Datetime.from_string(fields.Datetime.now()) - + relativedelta(months=period) - ) - if period - else date, - "date_payment_to": date_payment_to, - } - if agent: - vals["agent_ids"] = [(4, agent.id)] - wizard = self.make_settle_model.create(vals) - wizard.action_settle() - - def register_payment( - self, - invoice, - payment_date, - amount=None, - payment_difference_handling="reconcile", - ): - payment_model = self.env["account.payment.register"] - invoice.action_post() - if not amount: - amount = invoice.amount_total - ctx = { - "active_model": "account.move", - "active_ids": [invoice.id], - } - return ( - payment_model.with_context(ctx) - .create( - { - "payment_date": payment_date, - "amount": amount, - "journal_id": self.env["account.journal"] - .search([("type", "=", "bank")], limit=1) - .id, - "payment_method_id": self.env.ref( - "account.account_payment_method_manual_out" - ).id, - "payment_difference_handling": payment_difference_handling, - } - ) - .action_create_payments() - ) +class TestPartialSettlement(TestPartialSettlementCommon): def test_partial_payment_amount_settlement(self): sale_order = self._create_multi_line_sale_order( self.agent_monthly, self.partial_commission_net_paid @@ -202,8 +26,8 @@ def test_partial_payment_amount_settlement(self): payment_difference_handling="open", ) self.assertTrue(invoice._get_reconciled_invoices_partials()) - self._settle_agent(self.agent_monthly, 1, date_payment_to=datetime.now()) - settlements = self.env["sale.commission.settlement"].search( + self._settle_agent(self.agent_monthly, 1, datetime.now()) + settlements = self.env["commission.settlement"].search( [ ( "agent_id", @@ -217,30 +41,6 @@ def test_partial_payment_amount_settlement(self): self.assertEqual(2, len(settlements.line_ids)) self.assertEqual(2, len(invoice.line_ids.agent_ids)) - def test_skip_partial_future_payment(self): - sale_order = self._create_multi_line_sale_order( - self.agent_monthly, self.partial_commission_net_paid - ) - sale_order.action_confirm() - date = fields.Date.today() - invoice = self._invoice_sale_order(sale_order) - self.register_payment( - invoice, - date + relativedelta(days=2), - ) - self._settle_agent(self.agent_monthly, 1, date_payment_to=datetime.now()) - settlements = self.env["sale.commission.settlement"].search( - [ - ( - "agent_id", - "=", - self.agent_monthly.id, - ), - ("state", "=", "settled"), - ] - ) - self.assertEqual(0, len(settlements)) - def test_multi_agents_settlement(self): agent_net = self.agent_biweekly commission_net = self.commission_net_invoice diff --git a/sale_commission_partial_settlement/views/sale_commission_view.xml b/sale_commission_partial_settlement/views/commission_view.xml similarity index 56% rename from sale_commission_partial_settlement/views/sale_commission_view.xml rename to sale_commission_partial_settlement/views/commission_view.xml index b82c7b9d1..9dc52314f 100644 --- a/sale_commission_partial_settlement/views/sale_commission_view.xml +++ b/sale_commission_partial_settlement/views/commission_view.xml @@ -1,9 +1,9 @@ - - sale.commission.payment.amount.form - sale.commission - + + commission.partial.settlement.form.view + commission +