-
-
Notifications
You must be signed in to change notification settings - Fork 344
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[MIG] sale_commission_partial_settlement: Migration to 16.0
- Loading branch information
Showing
20 changed files
with
430 additions
and
416 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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" | ||
|
@@ -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" | ||
|
||
|
@@ -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" | ||
|
||
|
@@ -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" | ||
|
||
|
@@ -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" |
11 changes: 0 additions & 11 deletions
11
sale_commission_partial_settlement/migrations/14.0.1.0.1/post-migrate.py
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,6 @@ | ||
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 | ||
from . import commission_settlement_line |
109 changes: 109 additions & 0 deletions
109
sale_commission_partial_settlement/models/account_invoice_line_agent.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
# Copyright 2023 Nextev | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). | ||
|
||
from odoo import api, fields, models | ||
from odoo.tools.float_utils import float_compare | ||
|
||
|
||
class AccountInvoiceLineAgent(models.Model): | ||
_inherit = "account.invoice.line.agent" | ||
|
||
partial_settled = fields.Monetary( | ||
string="Partial Commission Amount Settled", | ||
compute="_compute_partial_settled", | ||
store=True, | ||
) | ||
is_fully_settled = fields.Boolean(compute="_compute_is_fully_settled", store=True) | ||
invoice_line_agent_partial_ids = fields.One2many( | ||
"account.invoice.line.agent.partial", "invoice_line_agent_id" | ||
) | ||
|
||
@api.depends( | ||
"invoice_line_agent_partial_ids.amount", | ||
"invoice_line_agent_partial_ids.agent_line.settlement_id.state", | ||
) | ||
def _compute_partial_settled(self): | ||
for rec in 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" | ||
) | ||
|
||
@api.depends( | ||
"commission_id.payment_amount_type", "amount", "settled", "partial_settled" | ||
) | ||
def _compute_is_fully_settled(self): | ||
for rec in self: | ||
if rec.commission_id.payment_amount_type != "paid": | ||
rec.is_fully_settled = rec.settled | ||
else: | ||
rec.is_fully_settled = rec.settled and ( | ||
float_compare( | ||
rec.partial_settled, | ||
rec.amount, | ||
precision_rounding=rec.currency_id.rounding, | ||
) | ||
== 0 | ||
) | ||
|
||
def _partial_commissions(self, date_payment_to): | ||
""" | ||
This method iterates through agent invoice lines and calculates | ||
partial commissions based on the payment amount. | ||
If the partial payment amount is greater than the invoice line | ||
amount, it fully settles the corresponding agent line. | ||
Otherwise, it calculates the partial commission proportionally to | ||
the amount paid, invoice amount and total commissions. | ||
""" | ||
partial_lines_to_settle = [] | ||
partial_payment_remaining = {} | ||
for line in self: | ||
line_total_amount = line.amount | ||
reconciled_partials, _ = line.invoice_id._get_reconciled_invoices_partials() | ||
for ( | ||
partial, | ||
amount, | ||
counterpart_line, | ||
) in reconciled_partials: | ||
if partial.partial_commission_settled: | ||
continue | ||
elif date_payment_to and date_payment_to < counterpart_line.date: | ||
break | ||
if partial.id in partial_payment_remaining: | ||
payment_amount = partial_payment_remaining[partial.id][ | ||
"remaining_amount" | ||
] | ||
else: | ||
payment_amount = amount | ||
partial_payment_remaining[partial.id] = {"remaining_amount": amount} | ||
if line.object_id.price_total <= payment_amount: | ||
partial_lines_to_settle.append( | ||
self._partial_agent_line_values( | ||
line, line_total_amount, partial | ||
) | ||
) | ||
partial_payment_remaining[partial.id] = { | ||
"remaining_amount": amount - line.object_id.price_total | ||
} | ||
break | ||
|
||
paid_in_proportion = payment_amount / line.invoice_id.amount_total | ||
partial_commission = ( | ||
line.invoice_id.commission_total * paid_in_proportion | ||
) | ||
partial_lines_to_settle.append( | ||
self._partial_agent_line_values(line, partial_commission, partial) | ||
) | ||
partial_agent_lines = self.env["account.invoice.line.agent.partial"].create( | ||
partial_lines_to_settle | ||
) | ||
return partial_agent_lines | ||
|
||
def _partial_agent_line_values(self, line, amount, partial): | ||
return { | ||
"invoice_line_agent_id": line.id, | ||
"currency_id": line.currency_id.id, | ||
"amount": amount, | ||
"account_partial_reconcile_id": partial.id, | ||
} |
23 changes: 23 additions & 0 deletions
23
sale_commission_partial_settlement/models/account_invoice_line_agent_partial.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
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, | ||
) | ||
account_partial_reconcile_id = fields.Many2one("account.partial.reconcile") | ||
amount = fields.Monetary( | ||
string="Commission Amount", | ||
) | ||
currency_id = fields.Many2one( | ||
related="invoice_line_agent_id.currency_id", | ||
) | ||
settled = fields.Boolean() |
Oops, something went wrong.