Skip to content

Commit

Permalink
[REF] Create membership_type
Browse files Browse the repository at this point in the history
Make membership_variable_period depend on it. This allows future modules
that also use the membership_type field.

Signed-off-by: Carmen Bianca BAKKER <[email protected]>
  • Loading branch information
carmenbianca committed Nov 24, 2023
1 parent 26b1073 commit f02f366
Show file tree
Hide file tree
Showing 16 changed files with 637 additions and 44 deletions.
86 changes: 86 additions & 0 deletions membership_type/README.rst
Original file line number Diff line number Diff line change
@@ -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 <https://github.com/OCA/vertical-association/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 <https://github.com/OCA/vertical-association/issues/new?body=module:%20membership_type%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.

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 <https://odoo-community.org/page/maintainer-role>`__:

|maintainer-carmenbianca|

This module is part of the `OCA/vertical-association <https://github.com/OCA/vertical-association/tree/16.0/membership_type>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
5 changes: 5 additions & 0 deletions membership_type/__init__.py
Original file line number Diff line number Diff line change
@@ -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
22 changes: 22 additions & 0 deletions membership_type/__manifest__.py
Original file line number Diff line number Diff line change
@@ -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": [],
}
5 changes: 5 additions & 0 deletions membership_type/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# SPDX-FileCopyrightText: 2023 Coop IT Easy SC
#
# SPDX-License-Identifier: AGPL-3.0-or-later

from . import product_template
50 changes: 50 additions & 0 deletions membership_type/models/product_template.py
Original file line number Diff line number Diff line change
@@ -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
3 changes: 3 additions & 0 deletions membership_type/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
* Coop IT Easy:

* Carmen Bianca BAKKER
1 change: 1 addition & 0 deletions membership_type/readme/DESCRIPTION.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
A small module that provides the scaffolding for membership types that interact differently with membership periods.
Loading

0 comments on commit f02f366

Please sign in to comment.