Skip to content

Commit

Permalink
[MIG] sale_commission_partial_settlement: Migration to 16.0
Browse files Browse the repository at this point in the history
  • Loading branch information
dalonsofl committed Sep 13, 2024
1 parent 0bb7f3e commit 3ae3861
Show file tree
Hide file tree
Showing 16 changed files with 294 additions and 333 deletions.
10 changes: 5 additions & 5 deletions sale_commission_partial_settlement/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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|
Expand All @@ -50,7 +50,7 @@ Bug Tracker
Bugs are tracked on `GitHub Issues <https://github.com/OCA/commission/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 <https://github.com/OCA/commission/issues/new?body=module:%20sale_commission_partial_settlement%0Aversion:%2014.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
`feedback <https://github.com/OCA/commission/issues/new?body=module:%20sale_commission_partial_settlement%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.

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

Expand Down Expand Up @@ -105,6 +105,6 @@ Current `maintainers <https://odoo-community.org/page/maintainer-role>`__:

|maintainer-aleuffre| |maintainer-renda-dev| |maintainer-PicchiSeba|

This module is part of the `OCA/commission <https://github.com/OCA/commission/tree/14.0/sale_commission_partial_settlement>`_ project on GitHub.
This module is part of the `OCA/commission <https://github.com/OCA/commission/tree/16.0/sale_commission_partial_settlement>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
4 changes: 2 additions & 2 deletions 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.0.1",
"version": "16.0.1.0.0",
"author": "Nextev Srl," "Ooops," "Odoo Community Association (OCA)",
"maintainers": ["aleuffre", "renda-dev", "PicchiSeba"],
"category": "Sales Management",
Expand All @@ -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,
}
69 changes: 27 additions & 42 deletions sale_commission_partial_settlement/i18n/es.po
Original file line number Diff line number Diff line change
Expand Up @@ -4,45 +4,45 @@
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 14.0\n"
"Project-Id-Version: Odoo Server 16.0\n"
"Report-Msgid-Bugs-To: \n"
"PO-Revision-Date: 2023-12-13 15:35+0000\n"
"Last-Translator: Ivorra78 <[email protected]>\n"
"Language-Team: none\n"
"Language: es\n"
"POT-Creation-Date: 2024-09-13 07:50+0000\n"
"PO-Revision-Date: 2024-09-13 07:50+0000\n"
"Last-Translator: \n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: nplurals=2; plural=n != 1;\n"
"X-Generator: Weblate 4.17\n"
"Plural-Forms: \n"

#. module: sale_commission_partial_settlement
#: model:ir.model.fields,field_description:sale_commission_partial_settlement.field_account_invoice_line_agent_partial__agent_line
msgid "Agent Line"
msgstr "Línea de Agente"

#. module: sale_commission_partial_settlement
#: model:ir.model.fields,field_description:sale_commission_partial_settlement.field_sale_commission_settlement_line__agent_line_partial_ids
#: model:ir.model.fields,field_description:sale_commission_partial_settlement.field_commission_settlement_line__agent_line_partial_ids
msgid "Agent Line Partial"
msgstr "Agente Línea Parcial"
msgstr "Línea de Agente Parcial"

#. module: sale_commission_partial_settlement
#: model:ir.model,name:sale_commission_partial_settlement.model_account_invoice_line_agent
msgid "Agent detail of commission line in invoice lines"
msgstr "Detalle de agente de línea de comisión en líneas de pedido"

#. module: sale_commission_partial_settlement
#: model:ir.model,name:sale_commission_partial_settlement.model_commission
msgid "Commission"
msgstr "Comisión"

#. module: sale_commission_partial_settlement
#: model:ir.model.fields,field_description:sale_commission_partial_settlement.field_account_invoice_line_agent_partial__amount
msgid "Commission Amount"
msgstr "Importe de la Comisión"

#. module: sale_commission_partial_settlement
#: model:ir.model,name:sale_commission_partial_settlement.model_sale_commission
msgid "Commission in sales"
msgstr "Comisión en ventas"

#. module: sale_commission_partial_settlement
#: code:addons/sale_commission_partial_settlement/wizard/wizard_settle.py:0
#. odoo-python
#: code:addons/sale_commission_partial_settlement/wizard/commission_make_settle.py:0
#, python-format
msgid "Created Settlements"
msgstr "Liquidaciones Creadas"
Expand All @@ -63,42 +63,27 @@ msgid "Currency"
msgstr "Divisa"

#. module: sale_commission_partial_settlement
#: model:ir.model.fields,field_description:sale_commission_partial_settlement.field_account_invoice_line_agent__display_name
#: model:ir.model.fields,field_description:sale_commission_partial_settlement.field_account_invoice_line_agent_partial__display_name
#: model:ir.model.fields,field_description:sale_commission_partial_settlement.field_account_partial_reconcile__display_name
#: model:ir.model.fields,field_description:sale_commission_partial_settlement.field_sale_commission__display_name
#: model:ir.model.fields,field_description:sale_commission_partial_settlement.field_sale_commission_make_settle__display_name
#: model:ir.model.fields,field_description:sale_commission_partial_settlement.field_sale_commission_settlement_line__display_name
msgid "Display Name"
msgstr "Nombre a Mostrar"

#. module: sale_commission_partial_settlement
#: model:ir.model.fields.selection,name:sale_commission_partial_settlement.selection__sale_commission__payment_amount_type__full
#: model:ir.model.fields.selection,name:sale_commission_partial_settlement.selection__commission__payment_amount_type__full
msgid "Full amount"
msgstr "Importe total"

#. module: sale_commission_partial_settlement
#: model:ir.model.fields,field_description:sale_commission_partial_settlement.field_account_invoice_line_agent__id
#: model:ir.model.fields,field_description:sale_commission_partial_settlement.field_account_invoice_line_agent_partial__id
#: model:ir.model.fields,field_description:sale_commission_partial_settlement.field_account_partial_reconcile__id
#: model:ir.model.fields,field_description:sale_commission_partial_settlement.field_sale_commission__id
#: model:ir.model.fields,field_description:sale_commission_partial_settlement.field_sale_commission_make_settle__id
#: model:ir.model.fields,field_description:sale_commission_partial_settlement.field_sale_commission_settlement_line__id
msgid "ID"
msgstr "ID"
msgstr ""

#. module: sale_commission_partial_settlement
#: model:ir.model.fields,field_description:sale_commission_partial_settlement.field_account_invoice_line_agent_partial__invoice_line_agent_id
msgid "Invoice Line Agent"
msgstr "Agente de Línea de Facturación"

#. module: sale_commission_partial_settlement
#: model:ir.model.fields,field_description:sale_commission_partial_settlement.field_account_invoice_line_agent____last_update
#: model:ir.model.fields,field_description:sale_commission_partial_settlement.field_account_invoice_line_agent_partial____last_update
#: model:ir.model.fields,field_description:sale_commission_partial_settlement.field_account_partial_reconcile____last_update
#: model:ir.model.fields,field_description:sale_commission_partial_settlement.field_sale_commission____last_update
#: model:ir.model.fields,field_description:sale_commission_partial_settlement.field_sale_commission_make_settle____last_update
#: model:ir.model.fields,field_description:sale_commission_partial_settlement.field_sale_commission_settlement_line____last_update
msgid "Last Modified on"
msgstr "Última Modificación el"

Expand All @@ -113,12 +98,12 @@ msgid "Last Updated on"
msgstr "Última Actualización el"

#. module: sale_commission_partial_settlement
#: model:ir.model,name:sale_commission_partial_settlement.model_sale_commission_settlement_line
#: model:ir.model,name:sale_commission_partial_settlement.model_commission_settlement_line
msgid "Line of a commission settlement"
msgstr "Línea de liquidación de comisión"
msgstr "Línea de liquidación de una comisión"

#. module: sale_commission_partial_settlement
#: model:ir.model.fields.selection,name:sale_commission_partial_settlement.selection__sale_commission__payment_amount_type__paid
#: model:ir.model.fields.selection,name:sale_commission_partial_settlement.selection__commission__payment_amount_type__paid
msgid "Paid amount"
msgstr "Importe pagado"

Expand All @@ -135,15 +120,15 @@ msgstr "Comisión Parcial Liquidada"
#. module: sale_commission_partial_settlement
#: model:ir.model,name:sale_commission_partial_settlement.model_account_partial_reconcile
msgid "Partial Reconcile"
msgstr "Conciliación Parcial"
msgstr "Conciliación parcial"

#. module: sale_commission_partial_settlement
#: model:ir.model,name:sale_commission_partial_settlement.model_account_invoice_line_agent_partial
msgid "Partial agent commissions"
msgstr "Comisiones parciales de agente"

#. module: sale_commission_partial_settlement
#: model:ir.model.fields,field_description:sale_commission_partial_settlement.field_sale_commission__payment_amount_type
#: model:ir.model.fields,field_description:sale_commission_partial_settlement.field_commission__payment_amount_type
msgid "Payment amount type"
msgstr "Tipo de importe del pago"

Expand All @@ -153,11 +138,11 @@ msgid "Settled"
msgstr "Liquidado"

#. module: sale_commission_partial_settlement
#: model:ir.model.fields,field_description:sale_commission_partial_settlement.field_sale_commission_settlement_line__settled_amount
#: model:ir.model.fields,field_description:sale_commission_partial_settlement.field_commission_settlement_line__settled_amount
msgid "Settled Amount"
msgstr "Importe Liquidado"
msgstr "Cantidad Liquidada"

#. module: sale_commission_partial_settlement
#: model:ir.model,name:sale_commission_partial_settlement.model_sale_commission_make_settle
msgid "Wizard for settling commissions in invoices"
msgstr "Asistente para liquidar comisiones en facturas"
#: model:ir.model,name:sale_commission_partial_settlement.model_commission_make_settle
msgid "Wizard for settling commissions"
msgstr "Asistente para liquidación de comisiones"

This file was deleted.

7 changes: 4 additions & 3 deletions sale_commission_partial_settlement/models/__init__.py
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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):
"""
Expand All @@ -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

Check warning on line 43 in sale_commission_partial_settlement/models/account_invoice_line_agent.py

View check run for this annotation

Codecov / codecov/patch

sale_commission_partial_settlement/models/account_invoice_line_agent.py#L43

Added line #L43 was not covered by tests
elif date_payment_to and date_payment_to < counterpart_line.date:
Expand All @@ -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,
Expand All @@ -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

Check warning on line 74 in sale_commission_partial_settlement/models/account_invoice_line_agent.py

View check run for this annotation

Codecov / codecov/patch

sale_commission_partial_settlement/models/account_invoice_line_agent.py#L74

Added line #L74 was not covered by tests
Expand All @@ -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,
}
Original file line number Diff line number Diff line change
@@ -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()
Original file line number Diff line number Diff line change
Expand Up @@ -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")],
Expand Down
Original file line number Diff line number Diff line change
@@ -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",
Expand All @@ -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

Check warning on line 24 in sale_commission_partial_settlement/models/commission_settlement_line.py

View check run for this annotation

Codecov / codecov/patch

sale_commission_partial_settlement/models/commission_settlement_line.py#L24

Added line #L24 was not covered by tests
else:
rec.settled_amount = rec.agent_line[:1].amount
rec.settled_amount = rec.invoice_agent_line_id[:1].amount
Loading

0 comments on commit 3ae3861

Please sign in to comment.