Skip to content

Commit

Permalink
[MIG] account_payment_term_extension: Migration to 18.0
Browse files Browse the repository at this point in the history
  • Loading branch information
TheMule71 committed Feb 5, 2025
1 parent 36c6f0c commit a28fe61
Show file tree
Hide file tree
Showing 11 changed files with 64 additions and 40 deletions.
15 changes: 8 additions & 7 deletions account_payment_term_extension/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ Payment Term Extension
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Faccount--payment-lightgray.png?logo=github
:target: https://github.com/OCA/account-payment/tree/17.0/account_payment_term_extension
:target: https://github.com/OCA/account-payment/tree/18.0/account_payment_term_extension
:alt: OCA/account-payment
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/account-payment-17-0/account-payment-17-0-account_payment_term_extension
:target: https://translation.odoo-community.org/projects/account-payment-18-0/account-payment-18-0-account_payment_term_extension
: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/account-payment&target_branch=17.0
:target: https://runboat.odoo-community.org/builds?repo=OCA/account-payment&target_branch=18.0
:alt: Try me on Runboat

|badge1| |badge2| |badge3| |badge4| |badge5|
Expand Down Expand Up @@ -95,7 +95,7 @@ Bug Tracker
Bugs are tracked on `GitHub Issues <https://github.com/OCA/account-payment/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/account-payment/issues/new?body=module:%20account_payment_term_extension%0Aversion:%2017.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
`feedback <https://github.com/OCA/account-payment/issues/new?body=module:%20account_payment_term_extension%0Aversion:%2018.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 @@ -136,12 +136,13 @@ Contributors
- Hoang <[email protected]>

- Anaïs López <[email protected]>
- Marco Colombo <[email protected]>

Other credits
-------------

The migration of this module from 15.0 to 16.0 was financially supported
by Camptocamp
The migration of this module from 17.0 to 18.0 was financially supported
by THERA S.R.L.

Maintainers
-----------
Expand All @@ -156,6 +157,6 @@ 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.

This module is part of the `OCA/account-payment <https://github.com/OCA/account-payment/tree/17.0/account_payment_term_extension>`_ project on GitHub.
This module is part of the `OCA/account-payment <https://github.com/OCA/account-payment/tree/18.0/account_payment_term_extension>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
2 changes: 1 addition & 1 deletion account_payment_term_extension/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

{
"name": "Payment Term Extension",
"version": "17.0.1.0.2",
"version": "18.0.1.0.0",
"category": "Accounting & Finance",
"summary": "Adds rounding, months, weeks and multiple payment days "
"properties on payment term lines",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Copyright 2025 Phi srl (Marco Colombo)
from openupgradelib import openupgrade

_xml_ids_renames = [
("view_payment_term_holiday_tree", "view_payment_term_holiday_list"),
]


@openupgrade.migrate()
def migrate(env, version):
openupgrade.rename_xmlids(env.cr, _xml_ids_renames)
8 changes: 5 additions & 3 deletions account_payment_term_extension/models/account_payment_term.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

from dateutil.relativedelta import relativedelta

from odoo import _, api, fields, models
from odoo import api, fields, models
from odoo.exceptions import UserError


Expand Down Expand Up @@ -88,7 +88,9 @@ def _compute_terms(
):
"""Complete overwrite of compute method for adding extra options."""
if cash_rounding:
raise UserError(_("This module is not compatible with cash rounding"))
raise UserError(

Check warning on line 91 in account_payment_term_extension/models/account_payment_term.py

View check run for this annotation

Codecov / codecov/patch

account_payment_term_extension/models/account_payment_term.py#L91

Added line #L91 was not covered by tests
self.env._("This module is not compatible with cash rounding")
)
# FIXME: Find an inheritable way of doing this
self.ensure_one()
company_currency = company.currency_id
Expand Down Expand Up @@ -165,7 +167,7 @@ def _compute_terms(
elif line.value == "percent_amount_untaxed":
if company_currency != currency:
raise UserError(

Check warning on line 169 in account_payment_term_extension/models/account_payment_term.py

View check run for this annotation

Codecov / codecov/patch

account_payment_term_extension/models/account_payment_term.py#L169

Added line #L169 was not covered by tests
_(
self.env._(
"Percentage of amount untaxed can't be used with foreign "
"currencies"
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).


from odoo import _, api, fields, models
from odoo import api, fields, models
from odoo.exceptions import ValidationError


Expand All @@ -26,7 +26,7 @@ def check_holiday(self):
record.date_postponed
) <= fields.Date.from_string(record.holiday):
raise ValidationError(
_("Holiday %s can only be postponed into the future")
self.env._("Holiday %s can only be postponed into the future")
% record.holiday
)
if (
Expand All @@ -39,7 +39,7 @@ def check_holiday(self):
> 1
):
raise ValidationError(
_("Holiday %s is duplicated in current payment term")
self.env._("Holiday %s is duplicated in current payment term")
% record.holiday
)
if (
Expand All @@ -54,6 +54,6 @@ def check_holiday(self):
>= 1
):
raise ValidationError(
_("Date %s cannot is both a holiday and a Postponed date")
self.env._("Date %s cannot is both a holiday and a Postponed date")
% record.holiday
)
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

from dateutil.relativedelta import relativedelta

from odoo import _, api, exceptions, fields, models
from odoo import api, exceptions, fields, models
from odoo.exceptions import ValidationError
from odoo.tools import date_utils
from odoo.tools.float_utils import float_round
Expand Down Expand Up @@ -97,7 +97,9 @@ def _check_payment_days(self):
except Exception:
error = True

Check warning on line 98 in account_payment_term_extension/models/account_payment_term_line.py

View check run for this annotation

Codecov / codecov/patch

account_payment_term_extension/models/account_payment_term_line.py#L97-L98

Added lines #L97 - L98 were not covered by tests
if error:
raise exceptions.Warning(_("Payment days field format is not valid."))
raise exceptions.Warning(

Check warning on line 100 in account_payment_term_extension/models/account_payment_term_line.py

View check run for this annotation

Codecov / codecov/patch

account_payment_term_extension/models/account_payment_term_line.py#L100

Added line #L100 was not covered by tests
self.env._("Payment days field format is not valid.")
)

def _get_due_date(self, date_ref):
res = super()._get_due_date(date_ref)
Expand Down Expand Up @@ -128,7 +130,7 @@ def _check_value_amount_untaxed(self):
and not 0 <= term_line.value_amount <= 100
):
raise ValidationError(
_(
self.env._(
"Percentages on the Payment Terms lines "
"must be between 0 and 100."
)
Expand Down
1 change: 1 addition & 0 deletions account_payment_term_extension/readme/CONTRIBUTORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@
- \`Trobz \<<https://trobz.com>\>\`:
- Hoang \<<[email protected]>\>
- Anaïs López \<<[email protected]>\>
- Marco Colombo \<<[email protected]>\>
4 changes: 2 additions & 2 deletions account_payment_term_extension/readme/CREDITS.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
The migration of this module from 15.0 to 16.0 was financially supported
by Camptocamp
The migration of this module from 17.0 to 18.0 was financially supported
by THERA S.R.L.
11 changes: 6 additions & 5 deletions account_payment_term_extension/static/description/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@ <h1 class="title">Payment Term Extension</h1>
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:79ddb630e827a8f93c5df7d7f977baba6cbf25b843980b9b57aee5a471f9bfb5
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/account-payment/tree/17.0/account_payment_term_extension"><img alt="OCA/account-payment" src="https://img.shields.io/badge/github-OCA%2Faccount--payment-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/account-payment-17-0/account-payment-17-0-account_payment_term_extension"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/account-payment&amp;target_branch=17.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/account-payment/tree/18.0/account_payment_term_extension"><img alt="OCA/account-payment" src="https://img.shields.io/badge/github-OCA%2Faccount--payment-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/account-payment-18-0/account-payment-18-0-account_payment_term_extension"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/account-payment&amp;target_branch=18.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
<p>This module extends the functionality of payment terms to:</p>
<ul class="simple">
<li>select “Percent (untaxed amount)” type in lines for using the base
Expand Down Expand Up @@ -445,7 +445,7 @@ <h1><a class="toc-backref" href="#toc-entry-4">Bug Tracker</a></h1>
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/account-payment/issues">GitHub Issues</a>.
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
<a class="reference external" href="https://github.com/OCA/account-payment/issues/new?body=module:%20account_payment_term_extension%0Aversion:%2017.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
<a class="reference external" href="https://github.com/OCA/account-payment/issues/new?body=module:%20account_payment_term_extension%0Aversion:%2018.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
<p>Do not contact contributors directly about support or help with technical issues.</p>
</div>
<div class="section" id="credits">
Expand Down Expand Up @@ -485,12 +485,13 @@ <h2><a class="toc-backref" href="#toc-entry-7">Contributors</a></h2>
</ul>
</li>
<li>Anaïs López &lt;<a class="reference external" href="mailto:anais.lopez&#64;forgeflow.com">anais.lopez&#64;forgeflow.com</a>&gt;</li>
<li>Marco Colombo &lt;<a class="reference external" href="mailto:marco.colombo&#64;phi.technology">marco.colombo&#64;phi.technology</a>&gt;</li>
</ul>
</div>
<div class="section" id="other-credits">
<h2><a class="toc-backref" href="#toc-entry-8">Other credits</a></h2>
<p>The migration of this module from 15.0 to 16.0 was financially supported
by Camptocamp</p>
<p>The migration of this module from 17.0 to 18.0 was financially supported
by THERA S.R.L.</p>
</div>
<div class="section" id="maintainers">
<h2><a class="toc-backref" href="#toc-entry-9">Maintainers</a></h2>
Expand All @@ -501,7 +502,7 @@ <h2><a class="toc-backref" href="#toc-entry-9">Maintainers</a></h2>
<p>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.</p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/account-payment/tree/17.0/account_payment_term_extension">OCA/account-payment</a> project on GitHub.</p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/account-payment/tree/18.0/account_payment_term_extension">OCA/account-payment</a> project on GitHub.</p>
<p>You are welcome to contribute. To learn how please visit <a class="reference external" href="https://odoo-community.org/page/Contribute">https://odoo-community.org/page/Contribute</a>.</p>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import odoo.tests.common as common
from odoo import fields
from odoo.exceptions import ValidationError
from odoo.tests.common import Form
from odoo.tests import Form


class TestAccountPaymentTermMultiDay(common.TransactionCase):
Expand Down Expand Up @@ -175,14 +175,20 @@ def _create_invoice(
return invoice

def test_amount_untaxed_payment_term_error(self):
payment_term_form = Form(self.payment_term_model)
payment_term_form.name = "10 percent + 40 percent + Balance"
payment_term_form.sequential_lines = True
with payment_term_form.line_ids.new() as line_form:
line_form.value = "percent_amount_untaxed"
line_form.value_amount = 110
vals = {
"name": "10 percent + 40 percent + Balance",
"sequential_lines": True,
"line_ids": [
fields.Command.create(
{
"value": "percent_amount_untaxed",
"value_amount": 110,
}
)
],
}
with self.assertRaises(ValidationError):
payment_term_form.save()
self.payment_term_model.create(vals)

def test_invoice_amount_untaxed_payment_term(self):
invoice = self._create_invoice(self.amount_untaxed_lines, "2020-01-01", 10, 100)
Expand Down
14 changes: 7 additions & 7 deletions account_payment_term_extension/views/account_payment_term.xml
Original file line number Diff line number Diff line change
@@ -1,35 +1,35 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo>
<record id="view_payment_term_holiday_tree" model="ir.ui.view">
<record id="view_payment_term_holiday_list" model="ir.ui.view">
<field name="name">Tree view for account.payment.term.holiday</field>
<field name="model">account.payment.term.holiday</field>
<field name="arch" type="xml">
<tree>
<list>
<field name="holiday" />
<field name="date_postponed" />
<field name="payment_id" />
</tree>
</list>
</field>
</record>
<record id="view_payment_term_form" model="ir.ui.view">
<field name="name">account.payment.term.form.extension</field>
<field name="model">account.payment.term</field>
<field name="inherit_id" ref="account.view_payment_term_form" />
<field name="arch" type="xml">
<field name="company_id" position="after">
<label for="early_discount" position="before">
<field name="sequential_lines" />
</field>
</label>
<data>
<xpath expr="//sheet" position="inside">
<separator string="Holidays" col="12" />
<p class="text-muted">
When a payment term coincides with a holiday, it is postponed to the chosen date.
</p>
<field name="holiday_ids" colspan="12">
<tree editable="top">
<list editable="top">
<field name="holiday" />
<field name="date_postponed" />
</tree>
</list>
</field>
</xpath>
</data>
Expand Down

0 comments on commit a28fe61

Please sign in to comment.