diff --git a/contract/README.rst b/contract/README.rst index 1c2dc198eb..73b79a554e 100644 --- a/contract/README.rst +++ b/contract/README.rst @@ -1,7 +1,3 @@ -.. image:: https://odoo-community.org/readme-banner-image - :target: https://odoo-community.org/get-involved?utm_source=readme - :alt: Odoo Community Association - ================================ Recurring - Contracts Management ================================ @@ -17,7 +13,7 @@ Recurring - Contracts Management .. |badge1| image:: https://img.shields.io/badge/maturity-Production%2FStable-green.png :target: https://odoo-community.org/page/development-status :alt: Production/Stable -.. |badge2| image:: https://img.shields.io/badge/license-AGPL--3-blue.png +.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html :alt: License: AGPL-3 .. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fcontract-lightgray.png?logo=github @@ -75,6 +71,9 @@ Usage - #START# - #END# or #INVOICEMONTHNAME# in the description field to display the start/end date or the start month of the invoiced period in the invoice line description + - #START-NEXT-MONTH# or #END-NEXT-MONTH# to display next month's + dates based on the invoice period start, useful when invoicing the + next month's services - pre-paid (invoice at period start) or post-paid (invoice at start of next period) diff --git a/contract/models/contract_line.py b/contract/models/contract_line.py index 5b8207c27f..f89dcdf69f 100644 --- a/contract/models/contract_line.py +++ b/contract/models/contract_line.py @@ -623,6 +623,18 @@ def _insert_markers(self, first_date_invoiced, last_date_invoiced): name = self.name name = name.replace("#START#", first_date_invoiced.strftime(date_format)) name = name.replace("#END#", last_date_invoiced.strftime(date_format)) + name = name.replace( + "#START-NEXT-MONTH#", + (first_date_invoiced + relativedelta(months=1, day=1)).strftime( + date_format + ), + ) + name = name.replace( + "#END-NEXT-MONTH#", + (first_date_invoiced + relativedelta(months=1, day=31)).strftime( + date_format + ), + ) name = name.replace( "#INVOICEMONTHNAME#", self.with_context(lang=lang.code)._translate_marker_month_name( diff --git a/contract/readme/USAGE.md b/contract/readme/USAGE.md index 8cc5f31818..746612671d 100644 --- a/contract/readme/USAGE.md +++ b/contract/readme/USAGE.md @@ -14,6 +14,9 @@ - \#START# - \#END# or \#INVOICEMONTHNAME# in the description field to display the start/end date or the start month of the invoiced period in the invoice line description + - \#START-NEXT-MONTH\# or \#END-NEXT-MONTH\# to display next month's + dates based on the invoice period start, useful when invoicing the + next month's services - pre-paid (invoice at period start) or post-paid (invoice at start of next period) 4. The "Generate Recurring Invoices from Contracts" cron runs daily to diff --git a/contract/static/description/index.html b/contract/static/description/index.html index 1aae071dcd..6ed10504b7 100644 --- a/contract/static/description/index.html +++ b/contract/static/description/index.html @@ -3,7 +3,7 @@ -README.rst +Recurring - Contracts Management -
+
+

Recurring - Contracts Management

- - -Odoo Community Association - -
-

Recurring - Contracts Management

-

Production/Stable License: AGPL-3 OCA/contract Translate me on Weblate Try me on Runboat

+

Production/Stable License: AGPL-3 OCA/contract Translate me on Weblate Try me on Runboat

This module enables contracts management with recurring invoicing functions. Also you can print and send by email contract report.

It works for customer contract and supplier contracts.

@@ -395,14 +390,14 @@

Recurring - Contracts Management

-

Configuration

+

Configuration

To view discount field in contract line, you need to set Discount on lines in user access rights.

Contracts can be viewed on the portal (list and detail) if the user logged into the portal is a follower of the contract.

-

Usage

+

Usage

  1. Contracts are in Invoicing -> Customers -> Customer and Invoicing -> Vendors -> Supplier Contracts
  2. @@ -422,6 +417,9 @@

    Usage

  3. #START# - #END# or #INVOICEMONTHNAME# in the description field to display the start/end date or the start month of the invoiced period in the invoice line description
  4. +
  5. #START-NEXT-MONTH# or #END-NEXT-MONTH# to display next month’s +dates based on the invoice period start, useful when invoicing the +next month’s services
  6. pre-paid (invoice at period start) or post-paid (invoice at start of next period)
  7. @@ -446,14 +444,14 @@

    Usage

    image2

-

Known issues / Roadmap

+

Known issues / Roadmap

  • Recover states and others functional fields in Contracts.
  • Add recurrence flag at template level.
-

Bug Tracker

+

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 @@ -461,16 +459,16 @@

Bug Tracker

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

-

Credits

+

Credits

-

Authors

+

Authors

  • Tecnativa
  • ACSONE SA/NV
-

Contributors

+

Contributors

-

Maintainers

+

Maintainers

This module is maintained by the OCA.

Odoo Community Association @@ -522,6 +520,5 @@

Maintainers

-
diff --git a/contract/tests/test_contract.py b/contract/tests/test_contract.py index 0559e30a2b..957fe7eced 100644 --- a/contract/tests/test_contract.py +++ b/contract/tests/test_contract.py @@ -166,6 +166,14 @@ def setUpClass(cls): "price_unit": 120, }, ), + ( + 0, + 0, + { + "name": "#START-NEXT-MONTH# - #END-NEXT-MONTH#", + "display_type": "line_note", + }, + ), ], } ) @@ -2403,6 +2411,7 @@ def test_check_month_name_marker(self): self.contract3.contract_line_ids.recurring_next_date = fields.Date.today() invoice_id = self.contract3.recurring_create_invoice() self.assertEqual(invoice_id.invoice_line_ids[0].name, "Header for May Services") + self.assertEqual(invoice_id.invoice_line_ids[3].name, "06/01/2023 - 06/30/2023") def test_analytic_account(self): """Tests the automatic setting of the analytic account on the contract diff --git a/contract/views/contract.xml b/contract/views/contract.xml index 0cac09f3c6..9a63d03bd9 100644 --- a/contract/views/contract.xml +++ b/contract/views/contract.xml @@ -478,6 +478,20 @@ the invoiced period

+

+ #START-NEXT-MONTH# + : Start + date + of the + next month +

+

+ #END-NEXT-MONTH# + : End date + of + the + next month +

#INVOICEMONTHNAME# : Invoice month name