Skip to content

Commit

Permalink
[ADD] membership_custom_date
Browse files Browse the repository at this point in the history
This module is needed for memberships that have a custom date range for
every individual.

The normal workflow when clicking on 'Buy Membership' does not involve
specifying the start and end dates. Rather, those dates are calculated
from the membership product. This calculation happens _after_ clicking
on 'Invoice Membership' in the wizard UI.

If we want to include the dates in the wizard UI, we disrupt this
workflow, and override the default behaviour of using the dates
configured in the membership product.

We circumvent this by only breaking the workflow for membership products
of type 'custom', which would be expected. We keep the workflow for
other types.

An alternative method is to calculate the dates from the product
selected in the wizard (onchange), but this is UX-wise incompatible with
the a downstream (non-OCA) requirement that the dates be changed to the
dates specified on another model (also onchange). So depending on which
field you changed last (product or project); that's the dates you get.
This is strange and unexpected behaviour.

Signed-off-by: Carmen Bianca BAKKER <[email protected]>
  • Loading branch information
carmenbianca committed Nov 24, 2023
1 parent f02f366 commit c50de6c
Show file tree
Hide file tree
Showing 15 changed files with 722 additions and 0 deletions.
87 changes: 87 additions & 0 deletions membership_custom_date/README.rst
Original file line number Diff line number Diff line change
@@ -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 <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_custom_date%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 SC

Contributors
~~~~~~~~~~~~

* `Coop IT Easy SC <https://coopiteasy.be>`_:

* 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_custom_date>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
6 changes: 6 additions & 0 deletions membership_custom_date/__init__.py
Original file line number Diff line number Diff line change
@@ -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
27 changes: 27 additions & 0 deletions membership_custom_date/__manifest__.py
Original file line number Diff line number Diff line change
@@ -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": [],
}
51 changes: 51 additions & 0 deletions membership_custom_date/i18n/fr.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * membership_custom_date
# Carmen Bianca Bakker <[email protected]>, 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 <[email protected]>\n"
"Language-Team: French <[email protected]>\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"
24 changes: 24 additions & 0 deletions membership_custom_date/i18n/membership_custom_date.pot
Original file line number Diff line number Diff line change
@@ -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 ""
5 changes: 5 additions & 0 deletions membership_custom_date/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# SPDX-FileCopyrightText: 2022 Coop IT Easy SC
#
# SPDX-License-Identifier: AGPL-3.0-or-later

from . import product_template
23 changes: 23 additions & 0 deletions membership_custom_date/models/product_template.py
Original file line number Diff line number Diff line change
@@ -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
3 changes: 3 additions & 0 deletions membership_custom_date/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
* `Coop IT Easy SC <https://coopiteasy.be>`_:

* Carmen Bianca Bakker
2 changes: 2 additions & 0 deletions membership_custom_date/readme/DESCRIPTION.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Memberships with custom dates have their dates specified on a
subscription-by-subscription basis.
Loading

0 comments on commit c50de6c

Please sign in to comment.