Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[16.0][REF/ADD] Create membership_type, membership_custom_date #161

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
28 changes: 28 additions & 0 deletions membership_custom_date/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# 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": [
"views/product_template_views.xml",
"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 ""
6 changes: 6 additions & 0 deletions membership_custom_date/models/__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 product_template
from . import membership_membership_line
24 changes: 24 additions & 0 deletions membership_custom_date/models/membership_membership_line.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# SPDX-FileCopyrightText: 2023 Coop IT Easy SC
#
# SPDX-License-Identifier: AGPL-3.0-or-later

from odoo import api, fields, models


class MembershipLine(models.Model):
_inherit = "membership.membership_line"

dates_mandatory = fields.Boolean(related="membership_id.dates_mandatory")

@api.constrains(
"membership_id",
"membership_type",
"dates_mandatory",
"date_from",
"date_to",
)
def _check_mandatory_dates(self):
lines = self.filtered(
lambda line: line.membership_type != "custom" or line.dates_mandatory
)
return super(MembershipLine, lines)._check_mandatory_dates()
31 changes: 31 additions & 0 deletions membership_custom_date/models/product_template.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# 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"},
)
dates_mandatory = fields.Boolean(
string="Mandatory dates",
default=True,
help="Membership lines that use this product must have a start and end date.",
)

@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
# TODO: should we set dates_mandatory back to True if switching away
# from custom? At the moment this variable is not used _at all_ for
# non-custom memberships.
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
Loading