diff --git a/membership_custom_date/README.rst b/membership_custom_date/README.rst new file mode 100644 index 00000000..4f44a208 --- /dev/null +++ b/membership_custom_date/README.rst @@ -0,0 +1,87 @@ +=========================== +Custom date for memberships +=========================== + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:1408ca166babe4521d36b67e7ebf366a2d53122b83aec7ca454397aed5a3163d + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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%2Fvertical--association-lightgray.png?logo=github + :target: https://github.com/OCA/vertical-association/tree/16.0/membership_custom_date + :alt: OCA/vertical-association +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/vertical-association-16-0/vertical-association-16-0-membership_custom_date + :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/vertical-association&target_branch=16.0 + :alt: Try me on Runboat + +|badge1| |badge2| |badge3| |badge4| |badge5| + +Memberships with custom dates have their dates specified on a +subscription-by-subscription basis. + +**Table of contents** + +.. contents:: + :local: + +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 +~~~~~~~ + +* Coop IT Easy SC + +Contributors +~~~~~~~~~~~~ + +* `Coop IT Easy SC `_: + + * Carmen Bianca Bakker + +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-carmenbianca| image:: https://github.com/carmenbianca.png?size=40px + :target: https://github.com/carmenbianca + :alt: carmenbianca + +Current `maintainer `__: + +|maintainer-carmenbianca| + +This module is part of the `OCA/vertical-association `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/membership_custom_date/__init__.py b/membership_custom_date/__init__.py new file mode 100644 index 00000000..7bf9c9c0 --- /dev/null +++ b/membership_custom_date/__init__.py @@ -0,0 +1,6 @@ +# SPDX-FileCopyrightText: 2022 Coop IT Easy SC +# +# SPDX-License-Identifier: AGPL-3.0-or-later + +from . import models +from . import wizard diff --git a/membership_custom_date/__manifest__.py b/membership_custom_date/__manifest__.py new file mode 100644 index 00000000..31e83254 --- /dev/null +++ b/membership_custom_date/__manifest__.py @@ -0,0 +1,27 @@ +# SPDX-FileCopyrightText: 2022 Coop IT Easy SC +# +# SPDX-License-Identifier: AGPL-3.0-or-later + +{ + "name": "Custom date for memberships", + "summary": """ + Memberships with custom dates have their dates specified on a + subscription-by-subscription basis.""", + "version": "16.0.1.0.0", + "category": "Association", + "website": "https://github.com/OCA/vertical-association", + "author": "Coop IT Easy SC, Odoo Community Association (OCA)", + "maintainers": ["carmenbianca"], + "license": "AGPL-3", + "application": False, + "depends": [ + "membership_extension", + "membership_type", + ], + "excludes": [], + "data": [ + "wizard/membership_invoice_views.xml", + ], + "demo": [], + "qweb": [], +} diff --git a/membership_custom_date/i18n/fr.po b/membership_custom_date/i18n/fr.po new file mode 100644 index 00000000..501bcfe6 --- /dev/null +++ b/membership_custom_date/i18n/fr.po @@ -0,0 +1,51 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * membership_custom_date +# Carmen Bianca Bakker , 2022. +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 16.0beta\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: \n" +"PO-Revision-Date: 2022-10-04 14:34+0200\n" +"Last-Translator: Carmen Bianca Bakker \n" +"Language-Team: French \n" +"Language: fr\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: Poedit 3.0.1\n" + +#. module: membership_custom_date +#: model:ir.model.fields.selection,name:membership_custom_date.selection__product_template__membership_type__custom +msgid "Custom dates" +msgstr "Dates personnalisées" + +#. module: membership_custom_date +#: model:ir.model.fields,field_description:membership_custom_date.field_membership_invoice__date_to +msgid "End Date" +msgstr "Date de fin" + +#. module: membership_custom_date +#: model:ir.model,name:membership_custom_date.model_membership_invoice +msgid "Membership Invoice" +msgstr "Facture d'adhésion" + +#. module: membership_custom_date +#: model:ir.model.fields,field_description:membership_custom_date.field_membership_invoice__product_id_type +#: model:ir.model.fields,field_description:membership_custom_date.field_product_product__membership_type +#: model:ir.model.fields,field_description:membership_custom_date.field_product_template__membership_type +msgid "Membership Type" +msgstr "Type d'adhésion" + +#. module: membership_custom_date +#: model:ir.model,name:membership_custom_date.model_product_template +msgid "Product" +msgstr "Produit" + +#. module: membership_custom_date +#: model:ir.model.fields,field_description:membership_custom_date.field_membership_invoice__date_from +msgid "Start Date" +msgstr "Date de début" diff --git a/membership_custom_date/i18n/membership_custom_date.pot b/membership_custom_date/i18n/membership_custom_date.pot new file mode 100644 index 00000000..39e29543 --- /dev/null +++ b/membership_custom_date/i18n/membership_custom_date.pot @@ -0,0 +1,24 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * membership_custom_date +# +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: membership_custom_date +#: model:ir.model,name:membership_custom_date.model_membership_invoice +msgid "Membership Invoice" +msgstr "" + +#. module: membership_custom_date +#: model:ir.model,name:membership_custom_date.model_product_template +msgid "Product" +msgstr "" diff --git a/membership_custom_date/models/__init__.py b/membership_custom_date/models/__init__.py new file mode 100644 index 00000000..8afbbed9 --- /dev/null +++ b/membership_custom_date/models/__init__.py @@ -0,0 +1,5 @@ +# SPDX-FileCopyrightText: 2022 Coop IT Easy SC +# +# SPDX-License-Identifier: AGPL-3.0-or-later + +from . import product_template diff --git a/membership_custom_date/models/product_template.py b/membership_custom_date/models/product_template.py new file mode 100644 index 00000000..41edd977 --- /dev/null +++ b/membership_custom_date/models/product_template.py @@ -0,0 +1,23 @@ +# SPDX-FileCopyrightText: 2022 Coop IT Easy SC +# +# SPDX-License-Identifier: AGPL-3.0-or-later + +from odoo import api, fields, models + + +class ProductTemplate(models.Model): + _inherit = "product.template" + + membership_type = fields.Selection( + selection_add=[ + ("custom", "Custom dates"), + ], + ondelete={"custom": "set default"}, + ) + + @api.model + def _correct_vals_membership_type(self, vals): + vals = super()._correct_vals_membership_type(vals) + if vals.get("membership_type") == "custom": + vals["membership_date_from"] = vals["membership_date_to"] = False + return vals diff --git a/membership_custom_date/readme/CONTRIBUTORS.rst b/membership_custom_date/readme/CONTRIBUTORS.rst new file mode 100644 index 00000000..d64451ed --- /dev/null +++ b/membership_custom_date/readme/CONTRIBUTORS.rst @@ -0,0 +1,3 @@ +* `Coop IT Easy SC `_: + + * Carmen Bianca Bakker diff --git a/membership_custom_date/readme/DESCRIPTION.rst b/membership_custom_date/readme/DESCRIPTION.rst new file mode 100644 index 00000000..79abf42f --- /dev/null +++ b/membership_custom_date/readme/DESCRIPTION.rst @@ -0,0 +1,2 @@ +Memberships with custom dates have their dates specified on a +subscription-by-subscription basis. diff --git a/membership_custom_date/static/description/index.html b/membership_custom_date/static/description/index.html new file mode 100644 index 00000000..39da6808 --- /dev/null +++ b/membership_custom_date/static/description/index.html @@ -0,0 +1,427 @@ + + + + + + +Custom date for memberships + + + +
+

Custom date for memberships

+ + +

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

+

Memberships with custom dates have their dates specified on a +subscription-by-subscription basis.

+

Table of contents

+ +
+

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

+
    +
  • Coop IT Easy SC
  • +
+
+
+

Contributors

+ +
+
+

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:

+

carmenbianca

+

This module is part of the OCA/vertical-association project on GitHub.

+

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

+
+
+
+ + diff --git a/membership_custom_date/wizard/__init__.py b/membership_custom_date/wizard/__init__.py new file mode 100644 index 00000000..ce5e00bd --- /dev/null +++ b/membership_custom_date/wizard/__init__.py @@ -0,0 +1,5 @@ +# SPDX-FileCopyrightText: 2022 Coop IT Easy SC +# +# SPDX-License-Identifier: AGPL-3.0-or-later + +from . import membership_invoice diff --git a/membership_custom_date/wizard/membership_invoice.py b/membership_custom_date/wizard/membership_invoice.py new file mode 100644 index 00000000..e49ec1fc --- /dev/null +++ b/membership_custom_date/wizard/membership_invoice.py @@ -0,0 +1,34 @@ +# SPDX-FileCopyrightText: 2022 Coop IT Easy SC +# +# SPDX-License-Identifier: AGPL-3.0-or-later + +from odoo import fields, models + + +class MembershipInvoice(models.TransientModel): + _inherit = "membership.invoice" + + date_from = fields.Date(string="Start Date", default=fields.Datetime.now) + date_to = fields.Date(string="End Date") + + product_id_type = fields.Selection( + string="Membership Type", + related="product_id.membership_type", + ) + + def membership_invoice(self): + res = super().membership_invoice() + + account_moves = self.env["account.move"].search(res["domain"]) + membership_lines = account_moves.mapped( + "invoice_line_ids.membership_lines" + ).filtered(lambda line: line.membership_id.membership_type == "custom") + + membership_lines.write( + { + "date_from": self.date_from, + "date_to": self.date_to, + } + ) + + return res diff --git a/membership_custom_date/wizard/membership_invoice_views.xml b/membership_custom_date/wizard/membership_invoice_views.xml new file mode 100644 index 00000000..7cfae3c7 --- /dev/null +++ b/membership_custom_date/wizard/membership_invoice_views.xml @@ -0,0 +1,21 @@ + + + + membership.invoice.view.form + membership.invoice + + + + + + + + + + diff --git a/setup/membership_custom_date/odoo/addons/membership_custom_date b/setup/membership_custom_date/odoo/addons/membership_custom_date new file mode 120000 index 00000000..a081e479 --- /dev/null +++ b/setup/membership_custom_date/odoo/addons/membership_custom_date @@ -0,0 +1 @@ +../../../../membership_custom_date \ No newline at end of file diff --git a/setup/membership_custom_date/setup.py b/setup/membership_custom_date/setup.py new file mode 100644 index 00000000..28c57bb6 --- /dev/null +++ b/setup/membership_custom_date/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +)