diff --git a/base_ebill_payment_contract/README.rst b/base_ebill_payment_contract/README.rst new file mode 100644 index 0000000000..501b8ca6a0 --- /dev/null +++ b/base_ebill_payment_contract/README.rst @@ -0,0 +1,103 @@ +=========================== +Base eBill Payment Contract +=========================== + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:305c1c00d3de8d5ef06c54ff8bad41c5051a5ad6725e4095da4399e76b8f3881 + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png + :target: https://odoo-community.org/page/development-status + :alt: Beta +.. |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%2Fedi-lightgray.png?logo=github + :target: https://github.com/OCA/edi/tree/17.0/base_ebill_payment_contract + :alt: OCA/edi +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/edi-17-0/edi-17-0-base_ebill_payment_contract + :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/edi&target_branch=17.0 + :alt: Try me on Runboat + +|badge1| |badge2| |badge3| |badge4| |badge5| + +The goal of this module is to be a common ground for ebilling addons. It +adds an ebill.payment.contract attached to a partner. Alone this module +has no purpose. It needs to be installed with a module that implements a +specific ebilling system. This depending module has to implement his own +'transmit.method'. + +**Table of contents** + +.. contents:: + :local: + +Usage +===== + +To use this module, you need to: + +1. Install a specific e-billing module (None are ready, yet) + +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 +`feedback `_. + +Do not contact contributors directly about support or help with technical issues. + +Credits +======= + +Authors +------- + +* Camptocamp + +Contributors +------------ + +- Thierry Ducrest +- Phuc Tran Thanh + +Other credits +------------- + +The development of this module has been financially supported by: + +- Camptocamp + +Maintainers +----------- + +This module is maintained by the OCA. + +.. image:: https://odoo-community.org/logo.png + :alt: Odoo Community Association + :target: https://odoo-community.org + +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. + +.. |maintainer-TDu| image:: https://github.com/TDu.png?size=40px + :target: https://github.com/TDu + :alt: TDu + +Current `maintainer `__: + +|maintainer-TDu| + +This module is part of the `OCA/edi `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/base_ebill_payment_contract/__init__.py b/base_ebill_payment_contract/__init__.py new file mode 100644 index 0000000000..0650744f6b --- /dev/null +++ b/base_ebill_payment_contract/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/base_ebill_payment_contract/__manifest__.py b/base_ebill_payment_contract/__manifest__.py new file mode 100644 index 0000000000..5fcef50f4c --- /dev/null +++ b/base_ebill_payment_contract/__manifest__.py @@ -0,0 +1,17 @@ +# Copyright 2020 Camptocamp SA +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +{ + "name": "Base eBill Payment Contract", + "summary": """ + Base for managing e-billing contracts""", + "version": "17.0.1.0.0", + "development_status": "Beta", + "license": "AGPL-3", + "author": "Camptocamp,Odoo Community Association (OCA)", + "maintainers": ["TDu"], + "website": "https://github.com/OCA/edi", + "depends": ["account_invoice_transmit_method"], + "data": ["security/ir.model.access.csv", "views/ebill_payment_contract.xml"], + "demo": ["demo/ebill_payment_contract.xml"], +} diff --git a/base_ebill_payment_contract/demo/ebill_payment_contract.xml b/base_ebill_payment_contract/demo/ebill_payment_contract.xml new file mode 100644 index 0000000000..359a61c541 --- /dev/null +++ b/base_ebill_payment_contract/demo/ebill_payment_contract.xml @@ -0,0 +1,13 @@ + + + + + draft + + + + + open + + + diff --git a/base_ebill_payment_contract/i18n/base_ebill_payment_contract.pot b/base_ebill_payment_contract/i18n/base_ebill_payment_contract.pot new file mode 100644 index 0000000000..8abe434a22 --- /dev/null +++ b/base_ebill_payment_contract/i18n/base_ebill_payment_contract.pot @@ -0,0 +1,116 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * base_ebill_payment_contract +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 16.0\n" +"Report-Msgid-Bugs-To: \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: base_ebill_payment_contract +#: model:ir.model.fields.selection,name:base_ebill_payment_contract.selection__ebill_payment_contract__state__cancel +msgid "Cancel" +msgstr "" + +#. module: base_ebill_payment_contract +#: model:ir.model,name:base_ebill_payment_contract.model_res_partner +msgid "Contact" +msgstr "" + +#. module: base_ebill_payment_contract +#: model:ir.model.fields,field_description:base_ebill_payment_contract.field_ebill_payment_contract__create_uid +msgid "Created by" +msgstr "" + +#. module: base_ebill_payment_contract +#: model:ir.model.fields,field_description:base_ebill_payment_contract.field_ebill_payment_contract__create_date +msgid "Created on" +msgstr "" + +#. module: base_ebill_payment_contract +#: model:ir.model.fields,field_description:base_ebill_payment_contract.field_ebill_payment_contract__partner_id +msgid "Customer" +msgstr "" + +#. module: base_ebill_payment_contract +#: model:ir.model.fields,field_description:base_ebill_payment_contract.field_ebill_payment_contract__display_name +msgid "Display Name" +msgstr "" + +#. module: base_ebill_payment_contract +#: model:ir.model.fields.selection,name:base_ebill_payment_contract.selection__ebill_payment_contract__state__draft +msgid "Draft" +msgstr "" + +#. module: base_ebill_payment_contract +#: model:ir.model.fields,field_description:base_ebill_payment_contract.field_ebill_payment_contract__date_end +msgid "End date" +msgstr "" + +#. module: base_ebill_payment_contract +#: model:ir.model.fields,field_description:base_ebill_payment_contract.field_ebill_payment_contract__id +msgid "ID" +msgstr "" + +#. module: base_ebill_payment_contract +#: model:ir.model.fields,field_description:base_ebill_payment_contract.field_ebill_payment_contract__is_valid +msgid "Is Valid" +msgstr "" + +#. module: base_ebill_payment_contract +#: model:ir.model.fields,field_description:base_ebill_payment_contract.field_ebill_payment_contract____last_update +msgid "Last Modified on" +msgstr "" + +#. module: base_ebill_payment_contract +#: model:ir.model.fields,field_description:base_ebill_payment_contract.field_ebill_payment_contract__write_uid +msgid "Last Updated by" +msgstr "" + +#. module: base_ebill_payment_contract +#: model:ir.model.fields,field_description:base_ebill_payment_contract.field_ebill_payment_contract__write_date +msgid "Last Updated on" +msgstr "" + +#. module: base_ebill_payment_contract +#: model:ir.model.fields,field_description:base_ebill_payment_contract.field_ebill_payment_contract__name +msgid "Name" +msgstr "" + +#. module: base_ebill_payment_contract +#: model:ir.model.fields.selection,name:base_ebill_payment_contract.selection__ebill_payment_contract__state__open +msgid "Open" +msgstr "" + +#. module: base_ebill_payment_contract +#: model:ir.model.fields,field_description:base_ebill_payment_contract.field_ebill_payment_contract__transmit_method_id +msgid "Service Name" +msgstr "" + +#. module: base_ebill_payment_contract +#: model:ir.model.fields,field_description:base_ebill_payment_contract.field_ebill_payment_contract__date_start +msgid "Start date" +msgstr "" + +#. module: base_ebill_payment_contract +#: model:ir.model.fields,field_description:base_ebill_payment_contract.field_ebill_payment_contract__state +msgid "State" +msgstr "" + +#. module: base_ebill_payment_contract +#: model_terms:ir.ui.view,arch_db:base_ebill_payment_contract.ebill_payment_contract_search_view +msgid "Valid" +msgstr "" + +#. module: base_ebill_payment_contract +#: model:ir.actions.act_window,name:base_ebill_payment_contract.ebill_payment_contract_act_window +#: model:ir.model,name:base_ebill_payment_contract.model_ebill_payment_contract +#: model:ir.ui.menu,name:base_ebill_payment_contract.ebill_payment_contract_menu +msgid "eBill Payment Contract" +msgstr "" diff --git a/base_ebill_payment_contract/i18n/es.po b/base_ebill_payment_contract/i18n/es.po new file mode 100644 index 0000000000..c849c05453 --- /dev/null +++ b/base_ebill_payment_contract/i18n/es.po @@ -0,0 +1,122 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * base_ebill_payment_contract +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 14.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2023-11-20 22:34+0000\n" +"Last-Translator: Ivorra78 \n" +"Language-Team: none\n" +"Language: es\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=2; plural=n != 1;\n" +"X-Generator: Weblate 4.17\n" + +#. module: base_ebill_payment_contract +#: model:ir.model.fields.selection,name:base_ebill_payment_contract.selection__ebill_payment_contract__state__cancel +msgid "Cancel" +msgstr "Cancelar" + +#. module: base_ebill_payment_contract +#: model:ir.model,name:base_ebill_payment_contract.model_res_partner +msgid "Contact" +msgstr "Contacto" + +#. module: base_ebill_payment_contract +#: model:ir.model.fields,field_description:base_ebill_payment_contract.field_ebill_payment_contract__create_uid +msgid "Created by" +msgstr "Creado por" + +#. module: base_ebill_payment_contract +#: model:ir.model.fields,field_description:base_ebill_payment_contract.field_ebill_payment_contract__create_date +msgid "Created on" +msgstr "Creado el" + +#. module: base_ebill_payment_contract +#: model:ir.model.fields,field_description:base_ebill_payment_contract.field_ebill_payment_contract__partner_id +msgid "Customer" +msgstr "Cliente" + +#. module: base_ebill_payment_contract +#: model:ir.model.fields,field_description:base_ebill_payment_contract.field_ebill_payment_contract__display_name +#: model:ir.model.fields,field_description:base_ebill_payment_contract.field_res_partner__display_name +msgid "Display Name" +msgstr "Mostrar Nombre" + +#. module: base_ebill_payment_contract +#: model:ir.model.fields.selection,name:base_ebill_payment_contract.selection__ebill_payment_contract__state__draft +msgid "Draft" +msgstr "Borrador" + +#. module: base_ebill_payment_contract +#: model:ir.model.fields,field_description:base_ebill_payment_contract.field_ebill_payment_contract__date_end +msgid "End date" +msgstr "Fecha Final" + +#. module: base_ebill_payment_contract +#: model:ir.model.fields,field_description:base_ebill_payment_contract.field_ebill_payment_contract__id +#: model:ir.model.fields,field_description:base_ebill_payment_contract.field_res_partner__id +msgid "ID" +msgstr "ID" + +#. module: base_ebill_payment_contract +#: model:ir.model.fields,field_description:base_ebill_payment_contract.field_ebill_payment_contract__is_valid +msgid "Is Valid" +msgstr "Es Válido" + +#. module: base_ebill_payment_contract +#: model:ir.model.fields,field_description:base_ebill_payment_contract.field_ebill_payment_contract____last_update +#: model:ir.model.fields,field_description:base_ebill_payment_contract.field_res_partner____last_update +msgid "Last Modified on" +msgstr "Última modificación el" + +#. module: base_ebill_payment_contract +#: model:ir.model.fields,field_description:base_ebill_payment_contract.field_ebill_payment_contract__write_uid +msgid "Last Updated by" +msgstr "Última Actualización por" + +#. module: base_ebill_payment_contract +#: model:ir.model.fields,field_description:base_ebill_payment_contract.field_ebill_payment_contract__write_date +msgid "Last Updated on" +msgstr "Última Actualización el" + +#. module: base_ebill_payment_contract +#: model:ir.model.fields,field_description:base_ebill_payment_contract.field_ebill_payment_contract__name +msgid "Name" +msgstr "Nombre" + +#. module: base_ebill_payment_contract +#: model:ir.model.fields.selection,name:base_ebill_payment_contract.selection__ebill_payment_contract__state__open +msgid "Open" +msgstr "Abrir" + +#. module: base_ebill_payment_contract +#: model:ir.model.fields,field_description:base_ebill_payment_contract.field_ebill_payment_contract__transmit_method_id +msgid "Service Name" +msgstr "Nombre del Servicio" + +#. module: base_ebill_payment_contract +#: model:ir.model.fields,field_description:base_ebill_payment_contract.field_ebill_payment_contract__date_start +msgid "Start date" +msgstr "Fecha Inicio" + +#. module: base_ebill_payment_contract +#: model:ir.model.fields,field_description:base_ebill_payment_contract.field_ebill_payment_contract__state +msgid "State" +msgstr "Estado" + +#. module: base_ebill_payment_contract +#: model_terms:ir.ui.view,arch_db:base_ebill_payment_contract.ebill_payment_contract_search_view +msgid "Valid" +msgstr "Válido" + +#. module: base_ebill_payment_contract +#: model:ir.actions.act_window,name:base_ebill_payment_contract.ebill_payment_contract_act_window +#: model:ir.model,name:base_ebill_payment_contract.model_ebill_payment_contract +#: model:ir.ui.menu,name:base_ebill_payment_contract.ebill_payment_contract_menu +msgid "eBill Payment Contract" +msgstr "Contrato de pago de facturas electrónicas" diff --git a/base_ebill_payment_contract/i18n/it.po b/base_ebill_payment_contract/i18n/it.po new file mode 100644 index 0000000000..8eaed6e1af --- /dev/null +++ b/base_ebill_payment_contract/i18n/it.po @@ -0,0 +1,119 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * base_ebill_payment_contract +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 16.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2024-08-23 12:06+0000\n" +"Last-Translator: mymage \n" +"Language-Team: none\n" +"Language: it\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=2; plural=n != 1;\n" +"X-Generator: Weblate 5.6.2\n" + +#. module: base_ebill_payment_contract +#: model:ir.model.fields.selection,name:base_ebill_payment_contract.selection__ebill_payment_contract__state__cancel +msgid "Cancel" +msgstr "Annulla" + +#. module: base_ebill_payment_contract +#: model:ir.model,name:base_ebill_payment_contract.model_res_partner +msgid "Contact" +msgstr "Contatto" + +#. module: base_ebill_payment_contract +#: model:ir.model.fields,field_description:base_ebill_payment_contract.field_ebill_payment_contract__create_uid +msgid "Created by" +msgstr "Creato da" + +#. module: base_ebill_payment_contract +#: model:ir.model.fields,field_description:base_ebill_payment_contract.field_ebill_payment_contract__create_date +msgid "Created on" +msgstr "Creato il" + +#. module: base_ebill_payment_contract +#: model:ir.model.fields,field_description:base_ebill_payment_contract.field_ebill_payment_contract__partner_id +msgid "Customer" +msgstr "Cliente" + +#. module: base_ebill_payment_contract +#: model:ir.model.fields,field_description:base_ebill_payment_contract.field_ebill_payment_contract__display_name +msgid "Display Name" +msgstr "Nome visualizzato" + +#. module: base_ebill_payment_contract +#: model:ir.model.fields.selection,name:base_ebill_payment_contract.selection__ebill_payment_contract__state__draft +msgid "Draft" +msgstr "Bozza" + +#. module: base_ebill_payment_contract +#: model:ir.model.fields,field_description:base_ebill_payment_contract.field_ebill_payment_contract__date_end +msgid "End date" +msgstr "Data fine" + +#. module: base_ebill_payment_contract +#: model:ir.model.fields,field_description:base_ebill_payment_contract.field_ebill_payment_contract__id +msgid "ID" +msgstr "ID" + +#. module: base_ebill_payment_contract +#: model:ir.model.fields,field_description:base_ebill_payment_contract.field_ebill_payment_contract__is_valid +msgid "Is Valid" +msgstr "È valido" + +#. module: base_ebill_payment_contract +#: model:ir.model.fields,field_description:base_ebill_payment_contract.field_ebill_payment_contract____last_update +msgid "Last Modified on" +msgstr "Ultima modifica il" + +#. module: base_ebill_payment_contract +#: model:ir.model.fields,field_description:base_ebill_payment_contract.field_ebill_payment_contract__write_uid +msgid "Last Updated by" +msgstr "Ultimo aggiornamento di" + +#. module: base_ebill_payment_contract +#: model:ir.model.fields,field_description:base_ebill_payment_contract.field_ebill_payment_contract__write_date +msgid "Last Updated on" +msgstr "Ultimo aggiornamento il" + +#. module: base_ebill_payment_contract +#: model:ir.model.fields,field_description:base_ebill_payment_contract.field_ebill_payment_contract__name +msgid "Name" +msgstr "Nome" + +#. module: base_ebill_payment_contract +#: model:ir.model.fields.selection,name:base_ebill_payment_contract.selection__ebill_payment_contract__state__open +msgid "Open" +msgstr "Aperto" + +#. module: base_ebill_payment_contract +#: model:ir.model.fields,field_description:base_ebill_payment_contract.field_ebill_payment_contract__transmit_method_id +msgid "Service Name" +msgstr "Nome servizio" + +#. module: base_ebill_payment_contract +#: model:ir.model.fields,field_description:base_ebill_payment_contract.field_ebill_payment_contract__date_start +msgid "Start date" +msgstr "Data inizio" + +#. module: base_ebill_payment_contract +#: model:ir.model.fields,field_description:base_ebill_payment_contract.field_ebill_payment_contract__state +msgid "State" +msgstr "Stato" + +#. module: base_ebill_payment_contract +#: model_terms:ir.ui.view,arch_db:base_ebill_payment_contract.ebill_payment_contract_search_view +msgid "Valid" +msgstr "Valido" + +#. module: base_ebill_payment_contract +#: model:ir.actions.act_window,name:base_ebill_payment_contract.ebill_payment_contract_act_window +#: model:ir.model,name:base_ebill_payment_contract.model_ebill_payment_contract +#: model:ir.ui.menu,name:base_ebill_payment_contract.ebill_payment_contract_menu +msgid "eBill Payment Contract" +msgstr "Contratto pagamento e-fattura" diff --git a/base_ebill_payment_contract/models/__init__.py b/base_ebill_payment_contract/models/__init__.py new file mode 100644 index 0000000000..bd9c1f908c --- /dev/null +++ b/base_ebill_payment_contract/models/__init__.py @@ -0,0 +1,2 @@ +from . import res_partner +from . import ebill_payment_contract diff --git a/base_ebill_payment_contract/models/ebill_payment_contract.py b/base_ebill_payment_contract/models/ebill_payment_contract.py new file mode 100644 index 0000000000..495ac57012 --- /dev/null +++ b/base_ebill_payment_contract/models/ebill_payment_contract.py @@ -0,0 +1,69 @@ +# Copyright 2020 Camptocamp SA +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from odoo import api, fields, models + + +class EbillPaymentContract(models.Model): + _name = "ebill.payment.contract" + _description = "eBill Payment Contract" + + transmit_method_id = fields.Many2one( + comodel_name="transmit.method", + string="Service Name", + ondelete="restrict", + ) + partner_id = fields.Many2one( + comodel_name="res.partner", required=True, string="Customer" + ) + name = fields.Char(related="partner_id.name") + date_start = fields.Date( + string="Start date", + required=True, + default=fields.Date.today, + ) + date_end = fields.Date(string="End date") + state = fields.Selection( + selection=[("draft", "Draft"), ("open", "Open"), ("cancel", "Cancel")], + required=True, + default="draft", + ) + is_valid = fields.Boolean(compute="_compute_is_valid", search="_search_is_valid") + + @api.onchange("state") + def _onchange_state(self): + """Change the end date if contract is canceled.""" + if self.state == "cancel" and self.date_end > fields.Date.today(): + self.date_end = fields.Date.today() + + @api.depends("state", "date_start", "date_end") + def _compute_is_valid(self): + """Check that the contract is valid + + It is valid if the contract is opened and its start date is in the past + And his end date is in the future or not set. + """ + today = fields.Date.today() + for contract in self: + contract.is_valid = ( + contract.state == "open" + and contract.date_start + and contract.date_start <= today + and (not contract.date_end or contract.date_end >= today) + ) + + def _search_is_valid(self, operator, value): + now = fields.Date.today() + domain = [ + ("state", "=", "open"), + ("date_start", "<=", now), + "|", + ("date_end", "=", False), + ("date_end", ">=", now), + ] + valid_contract = self.search(domain) + if (operator == "=" and value) or (operator == "!=" and not value): + new_operator = "in" + else: + new_operator = "not in" + return [("id", new_operator, valid_contract.ids)] diff --git a/base_ebill_payment_contract/models/res_partner.py b/base_ebill_payment_contract/models/res_partner.py new file mode 100644 index 0000000000..3cbaa8e7ba --- /dev/null +++ b/base_ebill_payment_contract/models/res_partner.py @@ -0,0 +1,30 @@ +# Copyright 2019 Camptocamp SA +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +import logging + +from odoo import models +from odoo.osv.expression import AND + +_logger = logging.getLogger(__name__) + + +class ResPartner(models.Model): + _inherit = "res.partner" + + def get_active_contract(self, transmit_method, domain=None): + """Return the active contract for a specific transmit method.""" + self.ensure_one() + base_domain = [ + ("is_valid", "=", True), + ("partner_id", "=", self.id), + ("transmit_method_id", "=", transmit_method.id), + ] + contract = self.env["ebill.payment.contract"].search( + AND([domain or [], base_domain]), limit=1 + ) + if not contract: + _logger.error( + f"eBill contract for {self.name} on {transmit_method.name} not found" + ) + return contract diff --git a/base_ebill_payment_contract/pyproject.toml b/base_ebill_payment_contract/pyproject.toml new file mode 100644 index 0000000000..4231d0cccb --- /dev/null +++ b/base_ebill_payment_contract/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["whool"] +build-backend = "whool.buildapi" diff --git a/base_ebill_payment_contract/readme/CONTRIBUTORS.md b/base_ebill_payment_contract/readme/CONTRIBUTORS.md new file mode 100644 index 0000000000..981771a624 --- /dev/null +++ b/base_ebill_payment_contract/readme/CONTRIBUTORS.md @@ -0,0 +1,2 @@ +- Thierry Ducrest \<\> +- Phuc Tran Thanh \<\> diff --git a/base_ebill_payment_contract/readme/CREDITS.md b/base_ebill_payment_contract/readme/CREDITS.md new file mode 100644 index 0000000000..705d3b30ca --- /dev/null +++ b/base_ebill_payment_contract/readme/CREDITS.md @@ -0,0 +1,3 @@ +The development of this module has been financially supported by: + +- Camptocamp diff --git a/base_ebill_payment_contract/readme/DESCRIPTION.md b/base_ebill_payment_contract/readme/DESCRIPTION.md new file mode 100644 index 0000000000..d51c6d463d --- /dev/null +++ b/base_ebill_payment_contract/readme/DESCRIPTION.md @@ -0,0 +1,5 @@ +The goal of this module is to be a common ground for ebilling addons. It +adds an ebill.payment.contract attached to a partner. Alone this module +has no purpose. It needs to be installed with a module that implements a +specific ebilling system. This depending module has to implement his own +'transmit.method'. diff --git a/base_ebill_payment_contract/readme/USAGE.md b/base_ebill_payment_contract/readme/USAGE.md new file mode 100644 index 0000000000..020954304e --- /dev/null +++ b/base_ebill_payment_contract/readme/USAGE.md @@ -0,0 +1,3 @@ +To use this module, you need to: + +1. Install a specific e-billing module (None are ready, yet) diff --git a/base_ebill_payment_contract/security/ir.model.access.csv b/base_ebill_payment_contract/security/ir.model.access.csv new file mode 100644 index 0000000000..899ad63e87 --- /dev/null +++ b/base_ebill_payment_contract/security/ir.model.access.csv @@ -0,0 +1,3 @@ +id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink +access_ebill_payment_contract_read,Read access on ebill.payment.contract to everybody,model_ebill_payment_contract,,1,0,0,0 +access_ebill_payment_contract_full,Full access on ebill.payment.contract to Financial Manager,model_ebill_payment_contract,account.group_account_manager,1,1,1,1 diff --git a/base_ebill_payment_contract/static/description/icon.png b/base_ebill_payment_contract/static/description/icon.png new file mode 100644 index 0000000000..3a0328b516 Binary files /dev/null and b/base_ebill_payment_contract/static/description/icon.png differ diff --git a/base_ebill_payment_contract/static/description/index.html b/base_ebill_payment_contract/static/description/index.html new file mode 100644 index 0000000000..3a9132bf7a --- /dev/null +++ b/base_ebill_payment_contract/static/description/index.html @@ -0,0 +1,446 @@ + + + + + +Base eBill Payment Contract + + + +
+

Base eBill Payment Contract

+ + +

Beta License: AGPL-3 OCA/edi Translate me on Weblate Try me on Runboat

+

The goal of this module is to be a common ground for ebilling addons. It +adds an ebill.payment.contract attached to a partner. Alone this module +has no purpose. It needs to be installed with a module that implements a +specific ebilling system. This depending module has to implement his own +‘transmit.method’.

+

Table of contents

+ +
+

Usage

+

To use this module, you need to:

+
    +
  1. Install a specific e-billing module (None are ready, yet)
  2. +
+
+
+

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 +feedback.

+

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

+
+
+

Credits

+
+

Authors

+
    +
  • Camptocamp
  • +
+
+
+

Contributors

+ +
+
+

Other credits

+

The development of this module has been financially supported by:

+
    +
  • Camptocamp
  • +
+
+
+

Maintainers

+

This module is maintained by the OCA.

+ +Odoo Community Association + +

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.

+

Current maintainer:

+

TDu

+

This module is part of the OCA/edi project on GitHub.

+

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

+
+
+
+ + diff --git a/base_ebill_payment_contract/tests/__init__.py b/base_ebill_payment_contract/tests/__init__.py new file mode 100644 index 0000000000..2133449459 --- /dev/null +++ b/base_ebill_payment_contract/tests/__init__.py @@ -0,0 +1 @@ +from . import test_base_ebill_payment_contract diff --git a/base_ebill_payment_contract/tests/test_base_ebill_payment_contract.py b/base_ebill_payment_contract/tests/test_base_ebill_payment_contract.py new file mode 100644 index 0000000000..b5fbd7a9b9 --- /dev/null +++ b/base_ebill_payment_contract/tests/test_base_ebill_payment_contract.py @@ -0,0 +1,70 @@ +# Copyright 2020 Camptocamp SA +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html) + +from datetime import date, timedelta + +from odoo.tests.common import Form, SingleTransactionCase + + +class TestBaseEbillPaymentContract(SingleTransactionCase): + @classmethod + def setUpClass(cls): + super().setUpClass() + cls.contract1 = cls.env.ref( + "base_ebill_payment_contract.ebill_payment_contract_demo_1" + ) + cls.partner = cls.contract1.partner_id + cls.method_post = cls.env.ref("account_invoice_transmit_method.post") + + def test_contract_validity(self): + self.contract1.state = "open" + # Contract starting today + self.contract1.date_start = date.today() + self.contract1.date_end = date.today() + timedelta(days=10) + self.assertTrue(self.contract1.is_valid) + # Contract finishing tomorrow + self.contract1.date_start = date.today() - timedelta(days=100) + self.contract1.date_end = date.today() + self.assertTrue(self.contract1.is_valid) + # Contract with no end date + self.contract1.date_start = date.today() - timedelta(days=100) + self.contract1.date_end = None + self.assertTrue(self.contract1.is_valid) + + def test_contract_is_not_valid(self): + self.contract1.state = "draft" + self.assertFalse(self.contract1.is_valid) + self.contract1.state = "cancel" + self.assertFalse(self.contract1.is_valid) + self.contract1.state = "open" + # Contract in the past + self.contract1.date_start = date.today() - timedelta(days=5) + self.contract1.date_end = date.today() - timedelta(days=1) + self.assertFalse(self.contract1.is_valid) + # Contract in the future + self.contract1.date_start = date.today() + timedelta(days=1) + self.contract1.date_end = date.today() + timedelta(days=5) + self.assertFalse(self.contract1.is_valid) + # Contract in the future with no end date + self.contract1.date_start = date.today() + timedelta(days=1) + self.contract1.date_end = None + self.assertFalse(self.contract1.is_valid) + + def test_contract_canceled(self): + """Check end date when contract is canceled.""" + self.contract1.date_start = date.today() - timedelta(days=6) + self.contract1.date_end = date.today() + timedelta(days=6) + self.contract1.state = "open" + with Form(self.contract1) as uiform: + uiform.state = "cancel" + self.assertEqual(date.today(), self.contract1.date_end) + + def test_contract_valid_different_transmition_method(self): + self.contract1.state = "open" + self.contract1.date_start = date.today() + self.contract1.date_end = date.today() + timedelta(days=10) + self.assertTrue(self.contract1.is_valid) + self.assertTrue( + self.partner.get_active_contract(self.contract1.transmit_method_id) + ) + self.assertFalse(self.partner.get_active_contract(self.method_post)) diff --git a/base_ebill_payment_contract/views/ebill_payment_contract.xml b/base_ebill_payment_contract/views/ebill_payment_contract.xml new file mode 100644 index 0000000000..d3f4378448 --- /dev/null +++ b/base_ebill_payment_contract/views/ebill_payment_contract.xml @@ -0,0 +1,64 @@ + + + + + ebill.payment.contract.form + ebill.payment.contract + +
+ + + + + + + + + +
+
+
+ + ebill.payment.contract.search + ebill.payment.contract + + + + + + + + + + ebill.payment.contract.tree + ebill.payment.contract + + + + + + + + + + + + + eBill Payment Contract + ebill.payment.contract + tree,form + [] + {} + + + eBill Payment Contract + + + + +