Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion contract/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Recurring - Contracts Management
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:fcbf0d9e74385728a9b6214b0550105168ee739aa8bb1dec3d63680a70413c66
!! source digest: sha256:d6e8454bf1db630a530d6bbf831fa37a084b8db5a3cc15e95a06a25e0908eea8
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

.. |badge1| image:: https://img.shields.io/badge/maturity-Production%2FStable-green.png
Expand Down Expand Up @@ -131,6 +131,9 @@ Contributors

* Antoni Marroig <amarroig@apsl.net>

* `Trey <https://www.trey.es>`__:
* Alejandro Bermudez <alex@trey.es>

Maintainers
~~~~~~~~~~~

Expand Down
18 changes: 18 additions & 0 deletions contract/i18n/contract.pot
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 16.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2025-06-26 10:37+0000\n"
"PO-Revision-Date: 2025-06-26 10:37+0000\n"
"Last-Translator: \n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
Expand Down Expand Up @@ -1163,6 +1165,7 @@ msgstr ""

#. module: contract
#: model:ir.model.fields,help:contract.field_contract_contract__message_has_error
#: model:ir.model.fields,help:contract.field_contract_contract__message_has_sms_error
msgid "If checked, some messages have a delivery error."
msgstr ""

Expand Down Expand Up @@ -1785,6 +1788,16 @@ msgstr ""
msgid "Recurring Invoices"
msgstr ""

#. module: contract
#: model:ir.model.fields,field_description:contract.field_contract_line__recurring_subtotal
msgid "Recurring Subtotal"
msgstr ""

#. module: contract
#: model:ir.model.fields,field_description:contract.field_contract_contract__recurring_total
msgid "Recurring Total"
msgstr ""

#. module: contract
#: model_terms:ir.ui.view,arch_db:contract.contract_contract_form_view
msgid "Recurring Type"
Expand Down Expand Up @@ -1848,6 +1861,11 @@ msgstr ""
msgid "Responsible User"
msgstr ""

#. module: contract
#: model:ir.model.fields,field_description:contract.field_contract_contract__message_has_sms_error
msgid "SMS Delivery error"
msgstr ""

#. module: contract
#: model:ir.model.fields,field_description:contract.field_res_partner__sale_contract_count
#: model:ir.model.fields,field_description:contract.field_res_users__sale_contract_count
Expand Down
30 changes: 23 additions & 7 deletions contract/i18n/es.po
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,16 @@ msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 11.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2020-12-31 14:54+0000\n"
"PO-Revision-Date: 2025-04-16 12:00+0000\n"
"POT-Creation-Date: 2025-06-26 10:37+0000\n"
"PO-Revision-Date: 2025-06-26 12:40+0200\n"
"Last-Translator: Carlos Sainz-Pardo Ortiz <carlos.sainz@netkia.es>\n"
"Language-Team: Spanish (https://www.transifex.com/oca/teams/23907/es/)\n"
"Language: es\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=n != 1;\n"
"X-Generator: Weblate 5.10.4\n"
"X-Generator: Poedit 3.0.1\n"

#. module: contract
#: model:mail.template,body_html:contract.email_contract_template
Expand Down Expand Up @@ -183,8 +183,8 @@ msgid ""
" "
msgstr ""
"<p>Hola,</p>\n"
" <p>Le notificamos que hay nuevas modificaciones en el "
"contrato.</p>\n"
" <p>Le notificamos que hay nuevas modificaciones en el contrato.</"
"p>\n"
" "

#. module: contract
Expand Down Expand Up @@ -831,8 +831,8 @@ msgid ""
msgstr ""
"Línea de contrato para <strong>%(product)s</strong>\n"
" parado: <br/>\n"
" - <strong>Fin</strong>: %(old_end)s -- %(new_end)"
"s\n"
" - <strong>Fin</strong>: %(old_end)s -- "
"%(new_end)s\n"
" "

#. module: contract
Expand Down Expand Up @@ -1342,6 +1342,7 @@ msgstr "Si está marcado los nuevos mensajes requieren su atención."

#. module: contract
#: model:ir.model.fields,help:contract.field_contract_contract__message_has_error
#: model:ir.model.fields,help:contract.field_contract_contract__message_has_sms_error
msgid "If checked, some messages have a delivery error."
msgstr "Si está marcado algunos mensajes tienen un error de entrega."

Expand Down Expand Up @@ -1974,6 +1975,16 @@ msgstr "Mixin de recurrencia para modelos contractuales"
msgid "Recurring Invoices"
msgstr "Facturas recurrentes"

#. module: contract
#: model:ir.model.fields,field_description:contract.field_contract_line__recurring_subtotal
msgid "Recurring Subtotal"
msgstr "Subtotal Recurrente"

#. module: contract
#: model:ir.model.fields,field_description:contract.field_contract_contract__recurring_total
msgid "Recurring Total"
msgstr "Total Recurrente"

#. module: contract
#: model_terms:ir.ui.view,arch_db:contract.contract_contract_form_view
msgid "Recurring Type"
Expand Down Expand Up @@ -2037,6 +2048,11 @@ msgstr "Responsable"
msgid "Responsible User"
msgstr "Usuario Responsable"

#. module: contract
#: model:ir.model.fields,field_description:contract.field_contract_contract__message_has_sms_error
msgid "SMS Delivery error"
msgstr "Mensaje de Error de entrega"

#. module: contract
#: model:ir.model.fields,field_description:contract.field_res_partner__sale_contract_count
#: model:ir.model.fields,field_description:contract.field_res_users__sale_contract_count
Expand Down
12 changes: 12 additions & 0 deletions contract/models/contract.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,11 @@ class ContractContract(models.Model):
inverse_name="contract_id",
string="Modifications",
)
recurring_total = fields.Monetary(
compute="_compute_recurring_total",
currency_field="currency_id",
store=True,
)

def get_formview_id(self, access_uid=None):
if self.contract_type == "sale":
Expand Down Expand Up @@ -717,3 +722,10 @@ def action_cancel_contract_termination(self):
"terminate_date": False,
}
)

@api.depends("contract_line_ids.recurring_subtotal")
def _compute_recurring_total(self):
for contract in self:
contract.recurring_total = sum(
contract.contract_line_ids.mapped("recurring_subtotal")
)
25 changes: 25 additions & 0 deletions contract/models/contract_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
# Copyright 2020 Tecnativa - Pedro M. Baeza
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

import math
from datetime import timedelta

from dateutil.relativedelta import relativedelta
Expand Down Expand Up @@ -100,6 +101,10 @@ class ContractLine(models.Model):
store=True,
readonly=True,
)
recurring_subtotal = fields.Monetary(
compute="_compute_recurring_subtotal",
currency_field="currency_id",
)

@api.depends(
"last_date_invoiced",
Expand Down Expand Up @@ -1119,3 +1124,23 @@ def _get_quantity_to_invoice(
):
self.ensure_one()
return self.quantity if not self.display_type else 0.0

@api.depends(
"price_unit", "quantity", "state", "recurring_rule_type", "recurring_interval"
)
def _compute_recurring_subtotal(self):
rule_type_dict = {
"daily": 365,
"weekly": 52,
"monthly": 12,
"monthlylastday": 12,
"quarterly": 4,
"semesterly": 2,
}
for line in self.filtered(lambda cl: cl.state != "canceled"):
rule_type = rule_type_dict.get(line.recurring_rule_type, 1)
interval = line.recurring_interval or 1
annual_frequency = math.floor(rule_type / interval)
line.recurring_subtotal = (
line.price_unit * annual_frequency
) * line.quantity
5 changes: 4 additions & 1 deletion contract/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,7 @@
* Iván Antón <ozono@ozonomultimedia.com>
* `[APSL] <https://www.apsl.tech>`_:

* Antoni Marroig <amarroig@apsl.net>
* Antoni Marroig <amarroig@apsl.net>

* `Trey <https://www.trey.es>`__:
* Alejandro Bermudez <alex@trey.es>
10 changes: 9 additions & 1 deletion contract/static/description/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ <h1 class="title">Recurring - Contracts Management</h1>
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:fcbf0d9e74385728a9b6214b0550105168ee739aa8bb1dec3d63680a70413c66
!! source digest: sha256:d6e8454bf1db630a530d6bbf831fa37a084b8db5a3cc15e95a06a25e0908eea8
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Production/Stable" src="https://img.shields.io/badge/maturity-Production%2FStable-green.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/contract/tree/16.0/contract"><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-16-0/contract-16-0-contract"><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=16.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
<p>This module enables contracts management with recurring
Expand Down Expand Up @@ -492,6 +492,14 @@ <h2><a class="toc-backref" href="#toc-entry-7">Contributors</a></h2>
</ul>
</blockquote>
</li>
<li><dl class="first docutils">
<dt><a class="reference external" href="https://www.trey.es">Trey</a>:</dt>
<dd><ul class="first last simple">
<li>Alejandro Bermudez &lt;<a class="reference external" href="mailto:alex&#64;trey.es">alex&#64;trey.es</a>&gt;</li>
</ul>
</dd>
</dl>
</li>
</ul>
</div>
<div class="section" id="maintainers">
Expand Down
15 changes: 15 additions & 0 deletions contract/views/contract.xml
Original file line number Diff line number Diff line change
Expand Up @@ -393,6 +393,20 @@
/>
</tree>
</field>
<group class="oe_right" colspan="2" name="recurring_total">
<div
class="oe_subtotal_footer_separator oe_inline o_td_label"
>
<label for="recurring_total" />
</div>
<field
name="recurring_total"
nolabel="1"
class="oe_subtotal_footer_separator"
widget="monetary"
options="{'currency_field': 'currency_id'}"
/>
</group>
<field name="note" />
</page>
<page name="modications" string="Modifications">
Expand Down Expand Up @@ -524,6 +538,7 @@
widget="many2many_tags"
options="{'color_field': 'color'}"
/>
<field name="recurring_total" optional="hide" />
<field name="active" invisible="1" />
<field name="company_id" groups="base.group_multi_company" />
</tree>
Expand Down
Loading