Skip to content

Commit c69c349

Browse files
[18.0][UPD] Updated sale_subscription,sale_subscription_line and sale_subscription_views to add sections and notes support
1 parent 9300823 commit c69c349

File tree

5 files changed

+46
-8
lines changed

5 files changed

+46
-8
lines changed

subscription_oca/README.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ Subscription management
1111
!! This file is generated by oca-gen-addon-readme !!
1212
!! changes will be overwritten. !!
1313
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
14-
!! source digest: sha256:ab6023e140886cb5c4fe2d8e969d404ab4a58de4701d6b906c424c9521d1b5d1
14+
!! source digest: sha256:bb329d140601b7b2d00180949e54d8e069943b704fc84d1fbdaf665386f79120
1515
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
1616
1717
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
@@ -102,6 +102,7 @@ Contributors
102102

103103
- Carlos Martínez <carlos@domatix.com>
104104
- Carolina Ferrer <carolina@domatix.com>
105+
- Alejandro Roser <alejandro@domatix.com>
105106
- `Ooops404 <https://www.ooops404.com>`__:
106107

107108
- Ilyas <irazor147@gmail.com>

subscription_oca/models/sale_subscription_line.py

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# Copyright 2023 Domatix - Carlos Martínez
22
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
3+
from dateutil.relativedelta import relativedelta
4+
35
from odoo import Command, api, fields, models
46
from odoo.tools.misc import get_lang
57

@@ -301,7 +303,8 @@ def _prepare_account_move_line(self):
301303
self.product_id.property_account_income_id
302304
or self.product_id.categ_id.property_account_income_categ_id
303305
)
304-
return {
306+
307+
vals = {
305308
"product_id": self.product_id.id,
306309
"name": self.name,
307310
"quantity": self.product_uom_qty,
@@ -313,3 +316,33 @@ def _prepare_account_move_line(self):
313316
"account_id": account.id,
314317
"analytic_distribution": self.analytic_distribution,
315318
}
319+
320+
if (
321+
self.sale_subscription_id
322+
and self.sale_subscription_id.recurring_next_date
323+
and vals.get("name")
324+
and ("#START#" in vals["name"] or "#END#" in vals["name"])
325+
):
326+
start_date = self.sale_subscription_id.recurring_next_date
327+
end_date = self.get_next_recurring_date(start_date)
328+
vals["name"] = self._insert_markers(start_date, end_date)
329+
330+
return vals
331+
332+
def get_next_recurring_date(self, date):
333+
template = self.sale_subscription_id.template_id
334+
type_interval = template.recurring_rule_type
335+
interval = int(template.recurring_interval)
336+
return date + relativedelta(**{type_interval: interval})
337+
338+
def _insert_markers(self, first_date_invoiced, last_date_invoiced):
339+
self.ensure_one()
340+
lang_obj = self.env["res.lang"]
341+
lang = lang_obj.search(
342+
[("code", "=", self.sale_subscription_id.partner_id.lang)]
343+
)
344+
date_format = lang.date_format or "%m/%d/%Y"
345+
name = self.name
346+
name = name.replace("#START#", first_date_invoiced.strftime(date_format))
347+
name = name.replace("#END#", last_date_invoiced.strftime(date_format))
348+
return name

subscription_oca/readme/CONTRIBUTORS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
- Carlos Martínez \<<carlos@domatix.com>\>
22
- Carolina Ferrer \<<carolina@domatix.com>\>
3+
- Alejandro Roser \<<alejandro@domatix.com>\>
34
- [Ooops404](https://www.ooops404.com):
45
- Ilyas \<<irazor147@gmail.com>\>
56
- [Sygel](https://www.sygel.es):

subscription_oca/readme/USAGE.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,10 @@ To make a subscription:
55
daily, monthly... and the method of creating the invoice and/or
66
order.
77
3. Go to *Subscription \> Subscriptions*.
8-
4. Create a subscription and indicate the start date. When the
9-
*Subscriptions Management* cron job is executed, the subscription
8+
4. Create a subscription and indicate the start date.You are able to pass
9+
the start and end dates to generated invoices by inserting #START# and
10+
#END# markers to the descriptions of the subscription invoce's products,
11+
When the *Subscriptions Management* cron job is executed, the subscription
1012
will begin and the first invoice will be created if the execution
1113
date matches the start date. The invoice will also be created when
1214
the execution date matches the next invoice date. Additionally, you

subscription_oca/static/description/index.html

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -372,9 +372,9 @@ <h1>Subscription management</h1>
372372
!! This file is generated by oca-gen-addon-readme !!
373373
!! changes will be overwritten. !!
374374
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
375-
!! source digest: sha256:ab6023e140886cb5c4fe2d8e969d404ab4a58de4701d6b906c424c9521d1b5d1
375+
!! source digest: sha256:bb329d140601b7b2d00180949e54d8e069943b704fc84d1fbdaf665386f79120
376376
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
377-
<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/license-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/contract/tree/18.0/subscription_oca"><img alt="OCA/contract" src="https://img.shields.io/badge/github-OCA%2Fcontract-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/contract-18-0/contract-18-0-subscription_oca"><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/contract&amp;target_branch=18.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
377+
<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/license-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/contract/tree/subscription-domatix/subscription_oca"><img alt="OCA/contract" src="https://img.shields.io/badge/github-OCA%2Fcontract-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/contract-subscription-domatix/contract-subscription-domatix-subscription_oca"><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/contract&amp;target_branch=subscription-domatix"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
378378
<p>This module allows creating subscriptions that generate recurring
379379
invoices or orders. It also enables the sale of products that generate
380380
subscriptions.</p>
@@ -435,7 +435,7 @@ <h2><a class="toc-backref" href="#toc-entry-3">Bug Tracker</a></h2>
435435
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/contract/issues">GitHub Issues</a>.
436436
In case of trouble, please check there if your issue has already been reported.
437437
If you spotted it first, help us to smash it by providing a detailed and welcomed
438-
<a class="reference external" href="https://github.com/OCA/contract/issues/new?body=module:%20subscription_oca%0Aversion:%2018.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
438+
<a class="reference external" href="https://github.com/OCA/contract/issues/new?body=module:%20subscription_oca%0Aversion:%20subscription-domatix%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
439439
<p>Do not contact contributors directly about support or help with technical issues.</p>
440440
</div>
441441
<div class="section" id="credits">
@@ -452,6 +452,7 @@ <h3><a class="toc-backref" href="#toc-entry-6">Contributors</a></h3>
452452
<ul class="simple">
453453
<li>Carlos Martínez &lt;<a class="reference external" href="mailto:carlos&#64;domatix.com">carlos&#64;domatix.com</a>&gt;</li>
454454
<li>Carolina Ferrer &lt;<a class="reference external" href="mailto:carolina&#64;domatix.com">carolina&#64;domatix.com</a>&gt;</li>
455+
<li>Alejandro Roser &lt;<a class="reference external" href="mailto:alejandro&#64;domatix.com">alejandro&#64;domatix.com</a>&gt;</li>
455456
<li><a class="reference external" href="https://www.ooops404.com">Ooops404</a>:<ul>
456457
<li>Ilyas &lt;<a class="reference external" href="mailto:irazor147&#64;gmail.com">irazor147&#64;gmail.com</a>&gt;</li>
457458
</ul>
@@ -474,7 +475,7 @@ <h3><a class="toc-backref" href="#toc-entry-7">Maintainers</a></h3>
474475
<p>OCA, or the Odoo Community Association, is a nonprofit organization whose
475476
mission is to support the collaborative development of Odoo features and
476477
promote its widespread use.</p>
477-
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/contract/tree/18.0/subscription_oca">OCA/contract</a> project on GitHub.</p>
478+
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/contract/tree/subscription-domatix/subscription_oca">OCA/contract</a> project on GitHub.</p>
478479
<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>
479480
</div>
480481
</div>

0 commit comments

Comments
 (0)