Skip to content

Commit

Permalink
[MIG] account_invoice_alternate_payer: Migration to 17.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Alpha Oumar committed Dec 11, 2024
1 parent 2c723fc commit a582495
Show file tree
Hide file tree
Showing 10 changed files with 146 additions and 144 deletions.
4 changes: 4 additions & 0 deletions account_invoice_alternate_payer/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,10 @@ Contributors

- Jordi Ballester Alomar <[email protected]>

- Auneor Conseil (https://www.auneor-conseil.fr)

- Alpha Oumar Sandaly DIALLO <[email protected]>

Maintainers
-----------

Expand Down
2 changes: 1 addition & 1 deletion account_invoice_alternate_payer/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
{
"name": "Account Invoice Alternate Payer",
"summary": "Set a alternate payor/payee in invoices",
"version": "16.0.1.0.0",
"version": "17.0.1.0.0",
"license": "AGPL-3",
"category": "Accounting",
"author": "Eficent,Odoo Community Association (OCA)",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 16.0\n"
"Project-Id-Version: Odoo Server 17.0+e\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2024-12-09 13:16+0000\n"
"PO-Revision-Date: 2024-12-09 13:16+0000\n"
"Last-Translator: \n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
Expand All @@ -17,7 +19,6 @@ msgstr ""
#: model:ir.model.fields,field_description:account_invoice_alternate_payer.field_account_bank_statement_line__alternate_payer_id
#: model:ir.model.fields,field_description:account_invoice_alternate_payer.field_account_move__alternate_payer_id
#: model:ir.model.fields,field_description:account_invoice_alternate_payer.field_account_payment__alternate_payer_id
#: model_terms:ir.ui.view,arch_db:account_invoice_alternate_payer.view_move_form
msgid "Alternate Payer"
msgstr ""

Expand Down Expand Up @@ -58,8 +59,3 @@ msgstr ""
#: model:ir.model,name:account_invoice_alternate_payer.model_account_payment
msgid "Payments"
msgstr ""

#. module: account_invoice_alternate_payer
#: model:ir.model,name:account_invoice_alternate_payer.model_account_payment_register
msgid "Register Payment"
msgstr ""
62 changes: 62 additions & 0 deletions account_invoice_alternate_payer/i18n/fr.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * account_invoice_alternate_payer
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 17.0+e\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2024-12-09 13:13+0000\n"
"PO-Revision-Date: 2024-12-09 13:13+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: \n"

#. module: account_invoice_alternate_payer
#: model:ir.model.fields,field_description:account_invoice_alternate_payer.field_account_bank_statement_line__alternate_payer_id
#: model:ir.model.fields,field_description:account_invoice_alternate_payer.field_account_move__alternate_payer_id
#: model:ir.model.fields,field_description:account_invoice_alternate_payer.field_account_payment__alternate_payer_id
msgid "Alternate Payer"
msgstr "Payeur"

#. module: account_invoice_alternate_payer
#: model:ir.model.fields,help:account_invoice_alternate_payer.field_account_bank_statement_line__alternate_payer_id
#: model:ir.model.fields,help:account_invoice_alternate_payer.field_account_move__alternate_payer_id
#: model:ir.model.fields,help:account_invoice_alternate_payer.field_account_payment__alternate_payer_id
msgid ""
"If set, this will be the partner that we expect to pay or to be paid by. If "
"not set, the payor is by default the commercial"
msgstr "S'il est défini, il s'agira du partenaire que nous prévoyons de payer ou par lequel nous prévoyons d'être payés."
"S'il n'est pas défini, le payeur est par défaut le partenaire commercial."

#. module: account_invoice_alternate_payer
#: model:ir.model,name:account_invoice_alternate_payer.model_account_move
msgid "Journal Entry"
msgstr "Pièce comptable"

#. module: account_invoice_alternate_payer
#: model:ir.model,name:account_invoice_alternate_payer.model_account_move_line
msgid "Journal Item"
msgstr "Écriture comptable"

#. module: account_invoice_alternate_payer
#. odoo-python
#: code:addons/account_invoice_alternate_payer/models/account_move.py:0
#, python-format
msgid "Outstanding credits"
msgstr "crédits en circulation"

#. module: account_invoice_alternate_payer
#. odoo-python
#: code:addons/account_invoice_alternate_payer/models/account_move.py:0
#, python-format
msgid "Outstanding debits"
msgstr "Débits en circulation"

#. module: account_invoice_alternate_payer
#: model:ir.model,name:account_invoice_alternate_payer.model_account_payment
msgid "Payments"
msgstr "Paiements"
73 changes: 38 additions & 35 deletions account_invoice_alternate_payer/models/account_move.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
from contextlib import contextmanager

from odoo import _, api, fields, models
from odoo.tools import float_is_zero


class AccountMove(models.Model):
Expand All @@ -13,8 +12,6 @@ class AccountMove(models.Model):
alternate_payer_id = fields.Many2one(
"res.partner",
string="Alternate Payer",
readonly=True,
states={"draft": [("readonly", False)]},
help="If set, this will be the partner that we expect to pay or to "
"be paid by. If not set, the payor is by default the "
"commercial",
Expand Down Expand Up @@ -75,68 +72,74 @@ def _compute_payments_widget_to_reconcile_info(self):
for move in self - super_moves:
move.invoice_outstanding_credits_debits_widget = False
move.invoice_has_outstanding = False

if (
move.state != "posted"
or move.payment_state != "not_paid"
or move.payment_state not in ("not_paid", "partial")
or not move.is_invoice(include_receipts=True)
):
continue
pay_term_line_ids = move.line_ids.filtered(

pay_term_lines = move.line_ids.filtered(
lambda line: line.account_id.account_type
in ("asset_receivable", "liability_payable")
)

domain = [
("account_id", "in", pay_term_line_ids.mapped("account_id").ids),
"|",
("move_id.state", "=", "posted"),
"&",
("move_id.state", "=", "draft"),
("account_id", "in", pay_term_lines.account_id.ids),
("parent_state", "=", "posted"),
("partner_id", "=", move.alternate_payer_id.id),
("reconciled", "=", False),
"|",
("amount_residual", "!=", 0.0),
("amount_residual_currency", "!=", 0.0),
]

payments_widget_vals = {
"outstanding": True,
"content": [],
"move_id": move.id,
}

if move.is_inbound():
domain.extend([("credit", ">", 0), ("debit", "=", 0)])
type_payment = _("Outstanding credits")
domain.append(("balance", "<", 0.0))
payments_widget_vals["title"] = _("Outstanding credits")
else:
domain.extend([("credit", "=", 0), ("debit", ">", 0)])
type_payment = _("Outstanding debits")
info = {"title": "", "outstanding": True, "content": [], "move_id": move.id}
lines = self.env["account.move.line"].search(domain)
currency_id = move.currency_id
for line in lines:
# get the outstanding residual value in invoice currency
if line.currency_id and line.currency_id == move.currency_id:
amount_to_show = abs(line.amount_residual_currency)
domain.append(("balance", ">", 0.0))
payments_widget_vals["title"] = _("Outstanding debits")

for line in self.env["account.move.line"].search(domain):
if line.currency_id == move.currency_id:
# Same foreign currency.
amount = abs(line.amount_residual_currency)
else:
currency = line.company_id.currency_id
amount_to_show = currency._convert(
# Different foreign currencies.
amount = line.company_currency_id._convert(
abs(line.amount_residual),
move.currency_id,
move.company_id,
line.date or fields.Date.today(),
line.date,
)
if float_is_zero(
amount_to_show, precision_rounding=move.currency_id.rounding
):

if move.currency_id.is_zero(amount):
continue
info["content"].append(

payments_widget_vals["content"].append(
{
"journal_name": line.ref or line.move_id.name,
"amount": amount_to_show,
"currency": currency_id.symbol,
"amount": amount,
"currency_id": move.currency_id.id,
"id": line.id,
"position": currency_id.position,
"digits": [69, move.currency_id.decimal_places],
"payment_date": fields.Date.to_string(line.date),
"move_id": line.move_id.id,
"date": fields.Date.to_string(line.date),
"account_payment_id": line.payment_id.id,
}
)
info["title"] = type_payment
move.invoice_outstanding_credits_debits_widget = info

if not payments_widget_vals["content"]:
continue

move.invoice_outstanding_credits_debits_widget = payments_widget_vals
move.invoice_has_outstanding = True
return super(
AccountMove, super_moves
Expand Down
12 changes: 0 additions & 12 deletions account_invoice_alternate_payer/models/account_payment.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,3 @@ def default_get(self, default_fields):
if invoices and invoices[0].alternate_payer_id:
rec.update({"partner_id": invoices[0].alternate_payer_id.id})
return rec


class AccountPaymentRegister(models.TransientModel):
_inherit = "account.payment.register"

def _prepare_payment_vals(self, invoices):
res = super()._prepare_payment_vals(invoices)
payer_id = (
invoices[0].alternate_payer_id.id or invoices[0].commercial_partner_id.id
)
res["partner_id"] = payer_id
return res
7 changes: 5 additions & 2 deletions account_invoice_alternate_payer/readme/CONTRIBUTORS.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
- Eficent Business and IT Consulting Services, S.L. (<https://www.eficent.com>)
- Jordi Ballester Alomar \<<[email protected]>\>
- Eficent Business and IT Consulting Services, S.L. (<https://www.eficent.com>)
- Jordi Ballester Alomar <<[email protected]>\>

- Auneor Conseil (https://www.auneor-conseil.fr)
- Alpha Oumar Sandaly DIALLO <<[email protected]>\>
4 changes: 4 additions & 0 deletions account_invoice_alternate_payer/static/description/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -416,6 +416,10 @@ <h2><a class="toc-backref" href="#toc-entry-5">Contributors</a></h2>
<li>Jordi Ballester Alomar &lt;<a class="reference external" href="mailto:jordi.ballester&#64;eficent.com">jordi.ballester&#64;eficent.com</a>&gt;</li>
</ul>
</li>
<li>Auneor Conseil (<a class="reference external" href="https://www.auneor-conseil.fr">https://www.auneor-conseil.fr</a>)<ul>
<li>Alpha Oumar Sandaly DIALLO &lt;<a class="reference external" href="mailto:alpha.oumar&#64;auneor-conseil.fr">alpha.oumar&#64;auneor-conseil.fr</a>&gt;</li>
</ul>
</li>
</ul>
</div>
<div class="section" id="maintainers">
Expand Down
Loading

0 comments on commit a582495

Please sign in to comment.