diff --git a/membership_type/README.rst b/membership_type/README.rst new file mode 100644 index 000000000..02163d032 --- /dev/null +++ b/membership_type/README.rst @@ -0,0 +1,86 @@ +================ +Membership types +================ + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:e4b8cd5d073b97106ebb8c15b9d9e0f948e06f275c08006523f2c937c943c7b1 + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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_type + :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_type + :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| + +A small module that provides the scaffolding for membership types that interact differently with membership periods. + +**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 + +Contributors +~~~~~~~~~~~~ + +* Coop IT Easy: + + * 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_type/__init__.py b/membership_type/__init__.py new file mode 100644 index 000000000..5fed47757 --- /dev/null +++ b/membership_type/__init__.py @@ -0,0 +1,5 @@ +# SPDX-FileCopyrightText: 2023 Coop IT Easy, Odoo Community Association (OCA) +# +# SPDX-License-Identifier: AGPL-3.0-or-later + +from . import models diff --git a/membership_type/__manifest__.py b/membership_type/__manifest__.py new file mode 100644 index 000000000..f8619b5ad --- /dev/null +++ b/membership_type/__manifest__.py @@ -0,0 +1,22 @@ +# SPDX-FileCopyrightText: 2023 Coop IT Easy, Odoo Community Association (OCA) +# +# SPDX-License-Identifier: AGPL-3.0-or-later + +{ + "name": "Membership types", + "summary": """ + A small module that provides the scaffolding for membership types that + interact differently with membership periods.""", + "version": "16.0.1.0.0", + "category": "Association", + "website": "https://github.com/OCA/vertical-association", + "author": "Coop IT Easy, Odoo Community Association (OCA)", + "maintainers": ["carmenbianca"], + "license": "AGPL-3", + "application": False, + "depends": ["membership_extension"], + "excludes": [], + "data": ["views/product_template_views.xml"], + "demo": [], + "qweb": [], +} diff --git a/membership_type/models/__init__.py b/membership_type/models/__init__.py new file mode 100644 index 000000000..00802a0ce --- /dev/null +++ b/membership_type/models/__init__.py @@ -0,0 +1,5 @@ +# SPDX-FileCopyrightText: 2023 Coop IT Easy SC +# +# SPDX-License-Identifier: AGPL-3.0-or-later + +from . import product_template diff --git a/membership_type/models/product_template.py b/membership_type/models/product_template.py new file mode 100644 index 000000000..410876bad --- /dev/null +++ b/membership_type/models/product_template.py @@ -0,0 +1,50 @@ +# Copyright 2015 Tecnativa - Pedro M. Baeza +# Copyright 2016 Tecnativa - Antonio Espinosa +# Copyright 2019 Onestein - Andrea Stirpe +# Copyright 2023 Coop IT Easy SC +# License AGPL-3 - See https://www.gnu.org/licenses/agpl-3.0.html + + +from odoo import api, fields, models + + +class ProductTemplate(models.Model): + _inherit = "product.template" + + membership_type = fields.Selection( + selection=[("fixed", "Fixed dates")], + default="fixed", + required=True, + ) + + @api.constrains( + "membership", + "membership_type", + ) + def _check_membership_dates(self): + return super( + ProductTemplate, + self.filtered(lambda record: record.membership_type == "fixed"), + )._check_membership_dates() + + @api.model + def _correct_vals_membership_type(self, vals): + """This method exists for downstream adopters to adjust some values + prior to writing/creating a record. Typically this is used to set + membership_date_from and membership_date_to to False. + """ + return vals + + @api.model_create_multi + def create(self, vals_list): + for vals in vals_list: + self._correct_vals_membership_type(vals) + return super().create(vals_list) + + def write(self, vals): + if not vals.get("membership_type"): + return super().write(vals) + for rec in self: + rec._correct_vals_membership_type(vals) + super(ProductTemplate, rec).write(vals) + return True diff --git a/membership_type/readme/CONTRIBUTORS.rst b/membership_type/readme/CONTRIBUTORS.rst new file mode 100644 index 000000000..6958b029a --- /dev/null +++ b/membership_type/readme/CONTRIBUTORS.rst @@ -0,0 +1,3 @@ +* Coop IT Easy: + + * Carmen Bianca BAKKER diff --git a/membership_type/readme/DESCRIPTION.rst b/membership_type/readme/DESCRIPTION.rst new file mode 100644 index 000000000..5b3a6ea6f --- /dev/null +++ b/membership_type/readme/DESCRIPTION.rst @@ -0,0 +1 @@ +A small module that provides the scaffolding for membership types that interact differently with membership periods. diff --git a/membership_type/static/description/index.html b/membership_type/static/description/index.html new file mode 100644 index 000000000..e2b56e681 --- /dev/null +++ b/membership_type/static/description/index.html @@ -0,0 +1,426 @@ + + + + + + +Membership types + + + +
+

Membership types

+ + +

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

+

A small module that provides the scaffolding for membership types that interact differently with membership periods.

+

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
  • +
+
+
+

Contributors

+
    +
  • Coop IT Easy:
      +
    • Carmen Bianca BAKKER
    • +
    +
  • +
+
+
+

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_type/views/product_template_views.xml b/membership_type/views/product_template_views.xml new file mode 100644 index 000000000..d8e49e979 --- /dev/null +++ b/membership_type/views/product_template_views.xml @@ -0,0 +1,18 @@ + + + + + Membership Products (type) + product.template + + + + + + diff --git a/membership_variable_period/README.rst b/membership_variable_period/README.rst index cb278a90f..dc4735f12 100644 --- a/membership_variable_period/README.rst +++ b/membership_variable_period/README.rst @@ -7,7 +7,7 @@ Variable period for memberships !! This file is generated by oca-gen-addon-readme !! !! changes will be overwritten. !! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - !! source digest: sha256:190d2bc541507eba23032a6748d377587100437992dd9cdea8ff6d890ac33f1e + !! source digest: sha256:d37bba15bf3d6072893e7b2fe9a22a2e2652f3058a7b93db53ce0f1206e093c3 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! .. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png diff --git a/membership_variable_period/__manifest__.py b/membership_variable_period/__manifest__.py index e20103e1b..7a6d1ef78 100644 --- a/membership_variable_period/__manifest__.py +++ b/membership_variable_period/__manifest__.py @@ -9,7 +9,10 @@ "category": "Association", "author": "Tecnativa, Onestein, Odoo Community Association (OCA)", "website": "https://github.com/OCA/vertical-association", - "depends": ["membership_extension"], + "depends": [ + "membership_extension", + "membership_type", + ], "data": ["views/product_template_views.xml"], "installable": True, } diff --git a/membership_variable_period/models/product_template.py b/membership_variable_period/models/product_template.py index 6884c9856..0deb02ab3 100644 --- a/membership_variable_period/models/product_template.py +++ b/membership_variable_period/models/product_template.py @@ -38,9 +38,8 @@ def _get_next_date(self, date, qty=1): return res # pragma: no cover membership_type = fields.Selection( - selection=[("fixed", "Fixed dates"), ("variable", "Variable periods")], - default="fixed", - required=True, + selection_add=[("variable", "Variable periods")], + ondelete={"variable": "set default"}, ) membership_interval_qty = fields.Integer( string="Interval quantity", @@ -63,40 +62,9 @@ def _get_next_date(self, date, qty=1): required=True, ) - def _correct_vals_membership_type(self, vals, membership_type): - if membership_type == "variable": + @api.model + def _correct_vals_membership_type(self, vals): + vals = super()._correct_vals_membership_type(vals) + if vals.get("membership_type") == "variable": vals["membership_date_from"] = vals["membership_date_to"] = False return vals - - @api.model_create_multi - def create(self, vals_list): - fixed_vals_list = [] - for vals in vals_list: - fixed_vals = vals.copy() - membership_type = fixed_vals.get("membership_type", "fixed") - fixed_vals = self._correct_vals_membership_type(fixed_vals, membership_type) - fixed_vals_list.append(fixed_vals) - return super().create(fixed_vals_list) - - def write(self, vals): - if not vals.get("membership_type"): - return super().write(vals) - for rec in self: - vals2 = vals.copy() - rec._correct_vals_membership_type( - vals2, vals.get("membership_type", rec.membership_type) - ) - super(ProductTemplate, rec).write(vals2) - return True - - @api.constrains( - "membership_date_from", - "membership_date_to", - "membership", - "membership_type", - ) - def _check_membership_dates(self): - return super( - ProductTemplate, - self.filtered(lambda record: record.membership_type == "fixed"), - )._check_membership_dates() diff --git a/membership_variable_period/static/description/index.html b/membership_variable_period/static/description/index.html index d1f7aefde..a488f3ff8 100644 --- a/membership_variable_period/static/description/index.html +++ b/membership_variable_period/static/description/index.html @@ -367,7 +367,7 @@

Variable period for memberships

!! This file is generated by oca-gen-addon-readme !! !! changes will be overwritten. !! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -!! source digest: sha256:190d2bc541507eba23032a6748d377587100437992dd9cdea8ff6d890ac33f1e +!! source digest: sha256:d37bba15bf3d6072893e7b2fe9a22a2e2652f3058a7b93db53ce0f1206e093c3 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->

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

Current membership module allows to set products that define a fixed period diff --git a/membership_variable_period/views/product_template_views.xml b/membership_variable_period/views/product_template_views.xml index f47e7984d..6743d274e 100644 --- a/membership_variable_period/views/product_template_views.xml +++ b/membership_variable_period/views/product_template_views.xml @@ -9,8 +9,7 @@ product.template -