diff --git a/ffck_commons/__manifest__.py b/ffck_commons/__manifest__.py index b6bbe42..8c062c8 100644 --- a/ffck_commons/__manifest__.py +++ b/ffck_commons/__manifest__.py @@ -13,25 +13,22 @@ "base", "contacts", "l10n_fr_association", - "partner_contact_age_range", - "partner_contact_birthdate", - "partner_contact_birthplace", - "partner_contact_gender", "partner_contact_email2", - "partner_contact_nationality", - "partner_contact_personal_information_page", "partner_contact_phones2", - "partner_firstname", ], "data": [ # Base data "data/ffck_structure_type.xml", + # membership data after structure data to papulate M2M field + "data/ffck_membership_type.xml", "data/res_partner.xml", "data/res_partner_age_range.xml", # Security "security/ir.model.access.csv", # Views "views/res_partner.xml", + # res_partner first for config menu + "views/ffck_membership_type.xml", "views/ffck_structure_type.xml", # Wizards # 'wizards/ir_model_wizard.xml', diff --git a/ffck_commons/data/ffck_membership_type.xml b/ffck_commons/data/ffck_membership_type.xml new file mode 100644 index 0000000..48c1fb4 --- /dev/null +++ b/ffck_commons/data/ffck_membership_type.xml @@ -0,0 +1,142 @@ + + + + + + 1 year competition adult + CA1A + 1 + year + adult + + + 64 + + + + + 1 year competition young + CJ1A + 1 + year + young + + + 42 + + + + + 1 year leisure adult + LA1A + 1 + year + adult + + + 56 + + + + + 1 year leisure young + LJ1A + 1 + year + young + + + 22 + + + + + 3 months adult + A3M + 3 + month + adult + + + 20 + + + + + 3 months young + J3M + 3 + month + young + + + 10 + + + + + 1 year without practice + SP1A + 1 + year + + + 2 + + + + + 1 day competition Open + C1D + 1 + day + + + 5 + + + + + 1 day leisure + L1D + 1 + day + + + 1 + + + + + 1 year individual + I1A + 1 + year + + + 80 + + + + + 1 year special NC and WF + SP1A + 1 + year + + + 5 + + + + + \ No newline at end of file diff --git a/ffck_commons/data/ffck_structure_type.xml b/ffck_commons/data/ffck_structure_type.xml index e5377c7..ddee7b5 100644 --- a/ffck_commons/data/ffck_structure_type.xml +++ b/ffck_commons/data/ffck_structure_type.xml @@ -6,12 +6,14 @@ Federation FFCK 1 + 0 Regional Committee CRCK 2 + 0 @@ -19,6 +21,7 @@ Departmental Committee CDCK 3 + 0 @@ -26,6 +29,7 @@ Affiliate member CLUB 4 + 320 @@ -33,6 +37,7 @@ Type A agreed member AGRA 4 + 320 @@ -40,6 +45,7 @@ Type B agreed member AGRB 4 + 320 @@ -47,6 +53,7 @@ Conventioned member CONV 4 + 0 diff --git a/ffck_commons/i18n/fr.po b/ffck_commons/i18n/fr.po index 880b1b5..e03bf11 100644 --- a/ffck_commons/i18n/fr.po +++ b/ffck_commons/i18n/fr.po @@ -6,8 +6,8 @@ msgid "" msgstr "" "Project-Id-Version: Odoo Server 16.0-20230613\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-05-27 21:44+0000\n" -"PO-Revision-Date: 2024-05-27 21:44+0000\n" +"POT-Creation-Date: 2024-05-29 12:59+0000\n" +"PO-Revision-Date: 2024-05-29 12:59+0000\n" "Last-Translator: \n" "Language-Team: \n" "MIME-Version: 1.0\n" @@ -16,6 +16,68 @@ msgstr "" "Plural-Forms: \n" #. module: ffck_commons +#: model:ffck.membership.type,name:ffck_commons.ffck_membership_type_c1d +msgid "1 day competition Open" +msgstr "Carte 1 jour Compétition Open" + +#. module: ffck_commons +#: model:ffck.membership.type,name:ffck_commons.ffck_membership_type_l1d +msgid "1 day leisure" +msgstr "Carte 1 jour Loisir" + +#. module: ffck_commons +#: model:ffck.membership.type,name:ffck_commons.ffck_membership_type_ca1a +msgid "1 year competition adult" +msgstr "Carte 1 an Compétition Adulte" + +#. module: ffck_commons +#: model:ffck.membership.type,name:ffck_commons.ffck_membership_type_cj1a +msgid "1 year competition young" +msgstr "Carte 1 an Compétition Jeune" + +#. module: ffck_commons +#: model:ffck.membership.type,name:ffck_commons.ffck_membership_type_i1a +msgid "1 year individual" +msgstr "Carte 1 an individuelle" + +#. module: ffck_commons +#: model:ffck.membership.type,name:ffck_commons.ffck_membership_type_la1a +msgid "1 year leisure adult" +msgstr "Carte 1 an Loisir Adulte" + +#. module: ffck_commons +#: model:ffck.membership.type,name:ffck_commons.ffck_membership_type_lj1a +msgid "1 year leisure young" +msgstr "Carte 1 an Loisir Jeune" + +#. module: ffck_commons +#: model:ffck.membership.type,name:ffck_commons.ffck_membership_type_sp1a +msgid "1 year special NC and WF" +msgstr "Carte 1 an spéciale NC et WF" + +#. module: ffck_commons +#: model:ffck.membership.type,name:ffck_commons.ffck_membership_type_sp1a +msgid "1 year without practice" +msgstr "Carte 1 an sans pratique" + +#. module: ffck_commons +#: model:ir.model.fields,field_description:ffck_commons.field_res_partner__first_membership_date +#: model:ir.model.fields,field_description:ffck_commons.field_res_users__first_membership_date +msgid "1st membership" +msgstr "Première adhésion" + +#. module: ffck_commons +#: model:ffck.membership.type,name:ffck_commons.ffck_membership_type_a3m +msgid "3 months adult" +msgstr "Carte 3 mois Loisir Adulte" + +#. module: ffck_commons +#: model:ffck.membership.type,name:ffck_commons.ffck_membership_type_j3m +msgid "3 months young" +msgstr "Carte 3 mois Loisir Jeune" + +#. module: ffck_commons +#: model:ir.model.fields,field_description:ffck_commons.field_ffck_membership_type__active #: model:ir.model.fields,field_description:ffck_commons.field_ffck_structure_type__active #: model:ir.model.fields,field_description:ffck_commons.field_res_partner_age_range__active #: model:ir.model.fields,field_description:ffck_commons.field_res_partner_hierarchy__active @@ -23,16 +85,39 @@ msgstr "" msgid "Active" msgstr "Actif" +#. module: ffck_commons +#: model:ir.model.fields.selection,name:ffck_commons.selection__ffck_membership_type__age_range__adult +#: model:ir.model.fields.selection,name:ffck_commons.selection__res_partner_age_range__age_range__adult +#: model_terms:ir.ui.view,arch_db:ffck_commons.ffck_membership_type_view_search +msgid "Adult" +msgstr "Adulte" + +#. module: ffck_commons +#: model_terms:ir.ui.view,arch_db:ffck_commons.res_partner_view_search_inherit_persons +msgid "Adults" +msgstr "Adultes" + #. module: ffck_commons #: model:ffck.structure.type,name:ffck_commons.ffck_structure_type_club msgid "Affiliate member" msgstr "Membre affilié" #. module: ffck_commons -#: model_terms:ir.ui.view,arch_db:ffck_commons.view_res_partner_filter_inherit_base +#: model_terms:ir.ui.view,arch_db:ffck_commons.ffck_membership_type_view_search +#: model_terms:ir.ui.view,arch_db:ffck_commons.res_partner_view_search_inherit_persons msgid "Age range" msgstr "Tranche d'âges" +#. module: ffck_commons +#: model:ir.model.fields,field_description:ffck_commons.field_ffck_membership_type__age_range +msgid "Age specific" +msgstr "Liée à l'âge" + +#. module: ffck_commons +#: model_terms:ir.ui.view,arch_db:ffck_commons.ffck_membership_type_view_search +msgid "Annual" +msgstr "Annuel" + #. module: ffck_commons #: model:res.partner.age.range,name:ffck_commons.age_range_benjamin msgid "Benjamin" @@ -55,6 +140,20 @@ msgstr "CRCK" msgid "Cadet" msgstr "" +#. module: ffck_commons +#: model:ir.model.fields,field_description:ffck_commons.field_ffck_membership_type__company_id +#: model:ir.model.fields,field_description:ffck_commons.field_ffck_structure_type__company_id +#: model_terms:ir.ui.view,arch_db:ffck_commons.ffck_membership_type_view_search +#: model_terms:ir.ui.view,arch_db:ffck_commons.ffck_structure_type_view_search +msgid "Company" +msgstr "Société" + +#. module: ffck_commons +#: model:ir.model.fields,field_description:ffck_commons.field_ffck_membership_type__competition +#: model_terms:ir.ui.view,arch_db:ffck_commons.ffck_membership_type_view_search +msgid "Competition" +msgstr "Compétition" + #. module: ffck_commons #: model:ir.model,name:ffck_commons.model_res_partner msgid "Contact" @@ -71,15 +170,39 @@ msgid "Create a Contact in your address book" msgstr "Créer un contact dans votre annuaire" #. module: ffck_commons +#: model:ir.model.fields,field_description:ffck_commons.field_ffck_membership_type__create_uid #: model:ir.model.fields,field_description:ffck_commons.field_ffck_structure_type__create_uid msgid "Created by" msgstr "Créé par" #. module: ffck_commons +#: model:ir.model.fields,field_description:ffck_commons.field_ffck_membership_type__create_date #: model:ir.model.fields,field_description:ffck_commons.field_ffck_structure_type__create_date msgid "Created on" msgstr "Créé le" +#. module: ffck_commons +#: model:ir.model.fields,field_description:ffck_commons.field_ffck_membership_type__currency_id +#: model:ir.model.fields,field_description:ffck_commons.field_ffck_structure_type__currency_id +msgid "Currency" +msgstr "Devise" + +#. module: ffck_commons +#: model:ir.model.fields,field_description:ffck_commons.field_ffck_membership_type__current_price +#: model:ir.model.fields,field_description:ffck_commons.field_ffck_structure_type__current_price +msgid "Current price" +msgstr "Prix actuel" + +#. module: ffck_commons +#: model_terms:ir.ui.view,arch_db:ffck_commons.ffck_membership_type_view_search +msgid "Daily" +msgstr "À la journée" + +#. module: ffck_commons +#: model:ir.model.fields.selection,name:ffck_commons.selection__ffck_membership_type__unit__day +msgid "Day" +msgstr "Jour" + #. module: ffck_commons #: model:ir.model.fields.selection,name:ffck_commons.selection__ffck_structure_type__scale__3 #: model:ir.model.fields.selection,name:ffck_commons.selection__res_partner__partner_scale__3 @@ -98,11 +221,17 @@ msgid "Departmental Committee" msgstr "Comité Départemental" #. module: ffck_commons +#: model:ir.model.fields,field_description:ffck_commons.field_ffck_membership_type__display_name #: model:ir.model.fields,field_description:ffck_commons.field_ffck_structure_type__display_name #: model:ir.model.fields,field_description:ffck_commons.field_res_partner_hierarchy__display_name msgid "Display Name" msgstr "Nom d'affichage" +#. module: ffck_commons +#: model:ir.model.fields,field_description:ffck_commons.field_ffck_membership_type__duration +msgid "Duration" +msgstr "Durée" + #. module: ffck_commons #: model:ir.model.fields,field_description:ffck_commons.field_res_partner__ffck_partner_code #: model:ir.model.fields,field_description:ffck_commons.field_res_users__ffck_partner_code @@ -128,6 +257,11 @@ msgstr "Code FFCK" msgid "FFCK code editable" msgstr "Code FFCK éditable" +#. module: ffck_commons +#: model:ir.actions.act_window,name:ffck_commons.ffck_membership_type_action +msgid "FFCK license types" +msgstr "Types de licences" + #. module: ffck_commons #: model:ir.model.fields,field_description:ffck_commons.field_res_partner__ffck_network #: model:ir.model.fields,field_description:ffck_commons.field_res_users__ffck_network @@ -147,6 +281,7 @@ msgid "FFCK partner" msgstr "FFCK" #. module: ffck_commons +#: model:ir.model,name:ffck_commons.model_ffck_membership_type #: model:ir.model,name:ffck_commons.model_ffck_structure_type msgid "FFCK structure type" msgstr "Type de structure" @@ -161,6 +296,13 @@ msgstr "Types de structures" msgid "Federation" msgstr "Fédération" +#. module: ffck_commons +#: model:ir.model.fields,field_description:ffck_commons.field_res_partner__age_range +#: model:ir.model.fields,field_description:ffck_commons.field_res_partner_age_range__age_range +#: model:ir.model.fields,field_description:ffck_commons.field_res_users__age_range +msgid "Global range" +msgstr "Tranche globale" + #. module: ffck_commons #: model_terms:ir.ui.view,arch_db:ffck_commons.view_res_partner_filter_inherit_base msgid "Hierarchy" @@ -173,6 +315,7 @@ msgid "Hierarchy element" msgstr "Hiérarchie" #. module: ffck_commons +#: model:ir.model.fields,field_description:ffck_commons.field_ffck_membership_type__id #: model:ir.model.fields,field_description:ffck_commons.field_ffck_structure_type__id #: model:ir.model.fields,field_description:ffck_commons.field_res_partner_hierarchy__id msgid "ID" @@ -184,26 +327,53 @@ msgid "Junior" msgstr "" #. module: ffck_commons +#: model:ir.model.fields,field_description:ffck_commons.field_ffck_membership_type____last_update #: model:ir.model.fields,field_description:ffck_commons.field_ffck_structure_type____last_update #: model:ir.model.fields,field_description:ffck_commons.field_res_partner_hierarchy____last_update msgid "Last Modified on" msgstr "Dernière modification le" #. module: ffck_commons +#: model:ir.model.fields,field_description:ffck_commons.field_ffck_membership_type__write_uid #: model:ir.model.fields,field_description:ffck_commons.field_ffck_structure_type__write_uid msgid "Last Updated by" msgstr "Dernière modification par" #. module: ffck_commons +#: model:ir.model.fields,field_description:ffck_commons.field_ffck_membership_type__write_date #: model:ir.model.fields,field_description:ffck_commons.field_ffck_structure_type__write_date msgid "Last Updated on" msgstr "Dernière mise à jour le" +#. module: ffck_commons +#: model:ir.model.fields,field_description:ffck_commons.field_res_partner__last_membership_date +#: model:ir.model.fields,field_description:ffck_commons.field_res_users__last_membership_date +msgid "Last membership" +msgstr "Dernière adhésion" + +#. module: ffck_commons +#: model_terms:ir.ui.view,arch_db:ffck_commons.ffck_membership_type_view_search +msgid "Leisure" +msgstr "Loisir" + #. module: ffck_commons #: model_terms:ir.ui.view,arch_db:ffck_commons.view_partner_form_inherit_base msgid "License code" msgstr "N° de licence" +#. module: ffck_commons +#: model:ir.model.fields,field_description:ffck_commons.field_res_partner__ffck_membership_type_id +#: model:ir.model.fields,field_description:ffck_commons.field_res_users__ffck_membership_type_id +#: model_terms:ir.ui.view,arch_db:ffck_commons.res_partner_view_search_inherit_persons +msgid "License type" +msgstr "Type de licence" + +#. module: ffck_commons +#: model:ir.model.fields,field_description:ffck_commons.field_ffck_structure_type__membership_type_ids +#: model:ir.ui.menu,name:ffck_commons.ffck_membership_type_menu +msgid "License types" +msgstr "Types de licence" + #. module: ffck_commons #: model:ir.model.fields.selection,name:ffck_commons.selection__ffck_structure_type__scale__5 #: model:ir.model.fields.selection,name:ffck_commons.selection__res_partner__partner_scale__5 @@ -249,6 +419,17 @@ msgid "Minime" msgstr "" #. module: ffck_commons +#: model:ir.model.fields.selection,name:ffck_commons.selection__ffck_membership_type__unit__month +msgid "Month" +msgstr "Mois" + +#. module: ffck_commons +#: model_terms:ir.ui.view,arch_db:ffck_commons.ffck_membership_type_view_search +msgid "Monthly" +msgstr "Au mois" + +#. module: ffck_commons +#: model:ir.model.fields,field_description:ffck_commons.field_ffck_membership_type__name #: model:ir.model.fields,field_description:ffck_commons.field_ffck_structure_type__name #: model:ir.model.fields,field_description:ffck_commons.field_res_partner_age_range__name #: model:ir.model.fields,field_description:ffck_commons.field_res_partner_hierarchy__name @@ -266,6 +447,11 @@ msgstr "Nationale" msgid "Network" msgstr "Réseau fédéral" +#. module: ffck_commons +#: model_terms:ir.ui.view,arch_db:ffck_commons.ffck_membership_type_view_search +msgid "No practice" +msgstr "Sans pratique" + #. module: ffck_commons #: model_terms:ir.actions.act_window,help:ffck_commons.action_persons msgid "Odoo helps you track all activities related to your contacts." @@ -274,6 +460,7 @@ msgstr "Odoo vous aide à suivre les activités liées à vos contacts" #. module: ffck_commons #: model:ir.model.fields,field_description:ffck_commons.field_ffck_structure_type__parent_id #: model:ir.model.fields,field_description:ffck_commons.field_res_partner_hierarchy__parent_id +#: model_terms:ir.ui.view,arch_db:ffck_commons.ffck_structure_type_view_search msgid "Parent" msgstr "" @@ -294,7 +481,6 @@ msgstr "Hiérarchie des partenaires" #. module: ffck_commons #: model:ir.actions.act_window,name:ffck_commons.action_persons -#: model:ir.ui.menu,name:ffck_commons.res_partner_menu_persons #: model_terms:ir.ui.view,arch_db:ffck_commons.view_res_partner_filter_inherit_base msgid "Persons" msgstr "Personnes" @@ -304,6 +490,21 @@ msgstr "Personnes" msgid "Poussin" msgstr "" +#. module: ffck_commons +#: model:ir.model.fields,field_description:ffck_commons.field_ffck_membership_type__practice +msgid "Practice" +msgstr "Pratique" + +#. module: ffck_commons +#: model:ir.model.fields,help:ffck_commons.field_ffck_membership_type__current_price +msgid "Price at which the license is currently sold." +msgstr "Prix auquel la licence est actuellement vendue." + +#. module: ffck_commons +#: model:ir.model.fields,help:ffck_commons.field_ffck_structure_type__current_price +msgid "Price at which the membership is currently sold." +msgstr "Prix auquel l'adhésion est actuellement vendue." + #. module: ffck_commons #: model:ir.model.fields.selection,name:ffck_commons.selection__ffck_structure_type__scale__2 #: model:ir.model.fields.selection,name:ffck_commons.selection__res_partner__partner_scale__2 @@ -325,25 +526,16 @@ msgstr "Comité Régional" #: model:ir.model.fields,field_description:ffck_commons.field_ffck_structure_type__scale #: model:ir.model.fields,field_description:ffck_commons.field_res_partner__partner_scale #: model:ir.model.fields,field_description:ffck_commons.field_res_users__partner_scale +#: model_terms:ir.ui.view,arch_db:ffck_commons.ffck_structure_type_view_search msgid "Scale" msgstr "Échelle" #. module: ffck_commons -#: model:res.partner.age.range,name:ffck_commons.age_range_senior -msgid "Senior" -msgstr "" - -#. module: ffck_commons +#: model:ir.model.fields,field_description:ffck_commons.field_ffck_membership_type__short #: model:ir.model.fields,field_description:ffck_commons.field_ffck_structure_type__short msgid "Short" msgstr "Initiales" -#. module: ffck_commons -#: model:ir.model.fields,field_description:ffck_commons.field_res_partner__first_membership_date -#: model:ir.model.fields,field_description:ffck_commons.field_res_users__first_membership_date -msgid "Structure 1st membership" -msgstr "Première adhésion" - #. module: ffck_commons #: model_terms:ir.ui.view,arch_db:ffck_commons.view_partner_form_inherit_base msgid "Structure code" @@ -367,6 +559,7 @@ msgid "Structure type" msgstr "Type de structure" #. module: ffck_commons +#: model:ir.model.fields,field_description:ffck_commons.field_ffck_membership_type__structure_type_ids #: model:ir.ui.menu,name:ffck_commons.ffck_structure_type_menu msgid "Structure types" msgstr "Types de structure" @@ -376,6 +569,17 @@ msgstr "Types de structure" msgid "Structures" msgstr "" +#. module: ffck_commons +#: model:res.partner.age.range,name:ffck_commons.age_range_senior +msgid "Sénior" +msgstr "" + +#. module: ffck_commons +#: model:ir.model.fields,field_description:ffck_commons.field_ffck_membership_type__unit +#: model_terms:ir.ui.view,arch_db:ffck_commons.ffck_membership_type_view_search +msgid "Time unit" +msgstr "Unité de temps" + #. module: ffck_commons #: model:ffck.structure.type,name:ffck_commons.ffck_structure_type_agra msgid "Type A agreed member" @@ -386,6 +590,12 @@ msgstr "Membre agréé Type A" msgid "Type B agreed member" msgstr "Membre agréé Type B" +#. module: ffck_commons +#: model:ir.model.fields,field_description:ffck_commons.field_res_partner__last_membership_validity +#: model:ir.model.fields,field_description:ffck_commons.field_res_users__last_membership_validity +msgid "Validity" +msgstr "Validité" + #. module: ffck_commons #: model:res.partner.age.range,name:ffck_commons.age_range_veteran1 msgid "Vétéran 1" @@ -410,3 +620,20 @@ msgstr "" #: model:res.partner.age.range,name:ffck_commons.age_range_veteran5 msgid "Vétéran 5" msgstr "" + +#. module: ffck_commons +#: model:ir.model.fields.selection,name:ffck_commons.selection__ffck_membership_type__unit__year +msgid "Year" +msgstr "An" + +#. module: ffck_commons +#: model:ir.model.fields.selection,name:ffck_commons.selection__ffck_membership_type__age_range__young +#: model:ir.model.fields.selection,name:ffck_commons.selection__res_partner_age_range__age_range__young +#: model_terms:ir.ui.view,arch_db:ffck_commons.ffck_membership_type_view_search +msgid "Young" +msgstr "Jeune" + +#. module: ffck_commons +#: model_terms:ir.ui.view,arch_db:ffck_commons.res_partner_view_search_inherit_persons +msgid "Youngs" +msgstr "Jeunes" diff --git a/ffck_commons/models/__init__.py b/ffck_commons/models/__init__.py index 7c2c57a..d984d27 100644 --- a/ffck_commons/models/__init__.py +++ b/ffck_commons/models/__init__.py @@ -1,4 +1,5 @@ # -*- coding: utf-8 -*- +from . import ffck_membership_type from . import ffck_structure_type from . import res_partner from . import res_partner_age_range diff --git a/ffck_commons/models/ffck_membership_type.py b/ffck_commons/models/ffck_membership_type.py new file mode 100644 index 0000000..649420d --- /dev/null +++ b/ffck_commons/models/ffck_membership_type.py @@ -0,0 +1,84 @@ +# -*- coding: utf-8 -*- +from odoo import models, fields + +RANGES = [ + ("young", "Young"), + ("adult", "Adult"), +] + +UNITS = [ + ("day", "Day"), + ("month", "Month"), + ("year", "Year"), +] + + +class FfckMembershipType(models.Model): + _name = "ffck.membership.type" + _description = "FFCK structure type" + _order = ( + "unit desc, duration desc, age_range, competition desc, practice desc, name, id" + ) + + active = fields.Boolean( + string="Active", + default=True, + ) + company_id = fields.Many2one( + comodel_name="res.company", + string="Company", + required=True, + default=lambda self: self.env.company, + ) + currency_id = fields.Many2one( + comodel_name="res.currency", + related="company_id.currency_id", + string="Currency", + readonly=True, + ) + name = fields.Char( + string="Name", + required=True, + translate=True, + ) + short = fields.Char( + string="Short", + required=True, + index=True, + ) + duration = fields.Integer( + string="Duration", + required=True, + default=1, + ) + unit = fields.Selection( + selection=UNITS, + string="Time unit", + required=True, + default="year", + ) + age_range = fields.Selection( + selection=RANGES, + string="Age specific", + ) + practice = fields.Boolean( + string="Practice", + default=True, + ) + competition = fields.Boolean( + string="Competition", + default=False, + ) + current_price = fields.Float( + string="Current price", + default=1.0, + digits="Product Price", + help="Price at which the license is currently sold.", + ) + structure_type_ids = fields.Many2many( + comodel_name="ffck.structure.type", + column1="membership_id", + column2="structure_type_id", + relation="membership_structure_type_rel", + string="Structure types", + ) diff --git a/ffck_commons/models/ffck_structure_type.py b/ffck_commons/models/ffck_structure_type.py index 874a02e..5bf0832 100644 --- a/ffck_commons/models/ffck_structure_type.py +++ b/ffck_commons/models/ffck_structure_type.py @@ -1,13 +1,6 @@ # -*- coding: utf-8 -*- from odoo import models, fields - -SCALES = [ - ("1", "National"), - ("2", "Regional"), - ("3", "Departmental"), - ("4", "Local"), - ("5", "Licensee"), -] +from .res_partner import SCALES class FfckStructureType(models.Model): @@ -15,8 +8,51 @@ class FfckStructureType(models.Model): _description = "FFCK structure type" _order = "scale, short, name, id" - name = fields.Char("Name", required=True, translate=True) - short = fields.Char("Short", required=True, index=True) - scale = fields.Selection(selection=SCALES, string="Scale", required=True) - active = fields.Boolean(string="Active", default=True) - parent_id = fields.Many2one(comodel_name="ffck.structure.type", string="Parent") + active = fields.Boolean( + string="Active", + default=True, + ) + company_id = fields.Many2one( + comodel_name="res.company", + string="Company", + required=True, + default=lambda self: self.env.company, + ) + currency_id = fields.Many2one( + comodel_name="res.currency", + related="company_id.currency_id", + string="Currency", + readonly=True, + ) + name = fields.Char( + "Name", + required=True, + translate=True, + ) + short = fields.Char( + "Short", + required=True, + index=True, + ) + scale = fields.Selection( + selection=SCALES, + string="Scale", + required=True, + ) + parent_id = fields.Many2one( + comodel_name="ffck.structure.type", + string="Parent", + ) + current_price = fields.Float( + string="Current price", + default=0.0, + digits="Product Price", + help="Price at which the membership is currently sold.", + ) + membership_type_ids = fields.Many2many( + comodel_name="ffck.membership.type", + column1="structure_type_id", + column2="membership_id", + relation="membership_structure_type_rel", + string="License types", + ) diff --git a/ffck_commons/models/res_partner.py b/ffck_commons/models/res_partner.py index bbdf3dd..12bf54a 100644 --- a/ffck_commons/models/res_partner.py +++ b/ffck_commons/models/res_partner.py @@ -1,7 +1,15 @@ # -*- coding: utf-8 -*- +from dateutil.relativedelta import relativedelta from odoo import models, fields, api from odoo.osv.expression import OR -from .ffck_structure_type import SCALES + +SCALES = [ + ("1", "National"), + ("2", "Regional"), + ("3", "Departmental"), + ("4", "Local"), + ("5", "Licensee"), +] class ResPartner(models.Model): @@ -10,7 +18,13 @@ class ResPartner(models.Model): # Partner fields ffck_network = fields.Boolean(string="FFCK network") - first_membership_date = fields.Date("Structure 1st membership") + first_membership_date = fields.Date("1st membership") + last_membership_date = fields.Date("Last membership") + last_membership_validity = fields.Date( + string="Validity", + compute="_get_membership_validity", + store=True, + ) # Structure typing partner_scale = fields.Selection( selection=SCALES, @@ -22,9 +36,22 @@ class ResPartner(models.Model): comodel_name="ffck.structure.type", string="Structure type", ) - partner_code = fields.Char(string="FFCK code", size=6, index=True) + age_range = fields.Selection( + related="age_range_id.age_range", + store=True, + ) + ffck_membership_type_id = fields.Many2one( + comodel_name="ffck.membership.type", + string="License type", + ) + partner_code = fields.Char( + string="FFCK code", + size=6, + index=True, + ) partner_code_editable = fields.Boolean( - string="FFCK code editable", default=True, readonly=True + string="FFCK code editable", + default=True, ) # FFCK ffck_partner_id = fields.Many2one( @@ -34,36 +61,44 @@ class ResPartner(models.Model): compute="_get_ffck_partner", store=True, ) - ffck_partner_code = fields.Char(string="FFCK", default="0", readonly=True) + ffck_partner_code = fields.Char( + string="FFCK", + default="0", + readonly=True, + ) # CRCK crck_partner_id = fields.Many2one( comodel_name="res.partner", string="CRCK partner", index=True, - ondelete="restrict", compute="_get_crck_partner", store=True, ) - crck_partner_code = fields.Char(related="crck_partner_id.partner_code", store=True) + crck_partner_code = fields.Char( + related="crck_partner_id.partner_code", + store=True, + ) # CDCK cdck_partner_id = fields.Many2one( comodel_name="res.partner", string="CDCK partner", index=True, - ondelete="restrict", compute="_get_cdck_partner", store=True, ) - cdck_partner_code = fields.Char(related="cdck_partner_id.partner_code", store=True) + cdck_partner_code = fields.Char( + related="cdck_partner_id.partner_code", + store=True, + ) local_partner_id = fields.Many2one( comodel_name="res.partner", string="Local partner", index=True, - ondelete="restrict", domain=[("ffck_network", "=", True), ("partner_scale", "=", 4)], ) local_partner_code = fields.Char( - related="local_partner_id.partner_code", store=True + related="local_partner_id.partner_code", + store=True, ) crck_partner_ids = fields.One2many( comodel_name="res.partner", @@ -115,6 +150,29 @@ class ResPartner(models.Model): # COMPUTES + @api.depends("last_membership_date", "ffck_membership_type_id") + def _get_membership_validity(self): + to_process = self.filtered("ffck_membership_type_id").filtered( + "last_membership_date" + ) + for partner in to_process: + date = partner.last_membership_date + year_end = date.replace(day=31, month=12) + membership = partner.ffck_membership_type_id + dur = membership.duration + unit = membership.unit + if unit == "day": + partner.last_membership_validity = date + relativedelta(days=dur - 1) + elif unit == "month": + partner.last_membership_validity = min( + date + relativedelta(days=-1, months=dur), + year_end, + ) + elif unit == "year": + partner.last_membership_validity = year_end + for partner in self - to_process: + partner.last_membership_validity = False + @api.depends( "is_company", "ffck_network", @@ -157,7 +215,7 @@ class ResPartner(models.Model): "cdck_partner_id", ) def _get_crck_partner(self): - cdck_ok = self.filtered("cdck_partner_id") + cdck_ok = self.filtered("cdck_partner_id.crck_partner_id") for partner in cdck_ok: partner.crck_partner_id = partner.cdck_partner_id.crck_partner_id todo = self - cdck_ok @@ -174,7 +232,7 @@ class ResPartner(models.Model): crck_by_state = {crck.state_id: crck for crck in crck_ok} concerned = todo.filtered( lambda rp: rp.ffck_network - and int(rp.partner_scale) >= 2 + and int(rp.partner_scale) >= 3 and rp.state_id in states_ok ) for partner in concerned: @@ -196,7 +254,7 @@ class ResPartner(models.Model): "country_department_id.code", ) def _get_cdck_partner(self): - local_ok = self.filtered("local_partner_id") + local_ok = self.filtered("local_partner_id.cdck_partner_id") for partner in local_ok: partner.cdck_partner_id = partner.local_partner_id.cdck_partner_id todo = self - local_ok @@ -206,7 +264,7 @@ class ResPartner(models.Model): and rp.ffck_network and rp.partner_code and len(rp.partner_code) >= 2 - and int(rp.partner_scale) in (3, 4) + and int(rp.partner_scale) == 4 ) licensees = todo.filtered( lambda rp: not rp.is_company @@ -335,7 +393,7 @@ class ResPartner(models.Model): @api.onchange("partner_code", "company_type", "ffck_network") def onchange_partner_code(self): - if self.ffck_network and self.is_company == False: + if self.ffck_network and not self.is_company: code = self.partner_code or "000000" if len(code) < 6: self.update({"partner_code": code.zfill(6)}) @@ -349,3 +407,11 @@ class ResPartner(models.Model): # for vals in vals_list: # vals.update({"partner_code_editable": False}) # return super().create(vals_list) + + def write(self, vals): + is_company = vals.get("is_company", None) + if is_company is True: + vals.update({"ffck_membership_type_id": False}) + if is_company is False: + vals.update({"ffck_structure_type_id": False}) + return super().write(vals) diff --git a/ffck_commons/models/res_partner_age_range.py b/ffck_commons/models/res_partner_age_range.py index abee99a..e35d961 100644 --- a/ffck_commons/models/res_partner_age_range.py +++ b/ffck_commons/models/res_partner_age_range.py @@ -3,10 +3,25 @@ from odoo import _, api, fields, models from odoo.exceptions import ValidationError +from .ffck_membership_type import RANGES class ResPartnerAgeRange(models.Model): _inherit = "res.partner.age.range" name = fields.Char(translate=True) + age_range = fields.Selection( + selection=RANGES, + string="Global range", + compute="_get_age_range", + store=True, + ) active = fields.Boolean(string="Active", default=True) + + @api.depends("age_to") + def _get_age_range(self): + for range in self: + if range.age_to <= 18: + range.age_range = "young" + else: + range.age_range = "adult" diff --git a/ffck_commons/security/ir.model.access.csv b/ffck_commons/security/ir.model.access.csv index 0c7c786..739eb85 100644 --- a/ffck_commons/security/ir.model.access.csv +++ b/ffck_commons/security/ir.model.access.csv @@ -1,4 +1,6 @@ id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink +access_ffck_membership_type_all,All ffck.membership.type,ffck_commons.model_ffck_membership_type,,1,0,0,0 +access_ffck_membership_type_group_partner_manager,Partner manager ffck.membership.type,ffck_commons.model_ffck_membership_type,base.group_system,1,1,1,0 access_ffck_structure_type_all,All ffck.structure.type,ffck_commons.model_ffck_structure_type,,1,0,0,0 -access_ffck_structure_type_group_partner_manager,Partner manager ffck.structure.type,ffck_commons.model_ffck_structure_type,base.group_partner_manager,1,1,1,0 +access_ffck_structure_type_group_partner_manager,Partner manager ffck.structure.type,ffck_commons.model_ffck_structure_type,base.group_system,1,1,1,0 access_res_partner_hierarchy_all,All res.partner.hierarchy,ffck_commons.model_res_partner_hierarchy,,1,0,0,0 \ No newline at end of file diff --git a/ffck_commons/views/ffck_membership_type.xml b/ffck_commons/views/ffck_membership_type.xml new file mode 100644 index 0000000..a14bfe9 --- /dev/null +++ b/ffck_commons/views/ffck_membership_type.xml @@ -0,0 +1,106 @@ + + + + + ffck.membership.type.view.form + ffck.membership.type + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ffck.membership.type.view.tree + ffck.membership.type + + + + + + + + + + + + + + + + + ffck.membership.type.view.search + ffck.membership.type + + + + + + + + + + + + + + + + + + + + + + + + + FFCK license types + ffck.membership.type + tree,form + [] + {} + + + + + \ No newline at end of file diff --git a/ffck_commons/views/ffck_structure_type.xml b/ffck_commons/views/ffck_structure_type.xml index 93bccc3..d5fbcc8 100644 --- a/ffck_commons/views/ffck_structure_type.xml +++ b/ffck_commons/views/ffck_structure_type.xml @@ -7,13 +7,30 @@ + + + - + + + - - - - + + + + + + + + + + + + + + + + @@ -25,14 +42,37 @@ ffck.structure.type + + + - + + + + + ffck.structure.type.view.search + ffck.structure.type + + + + + + + + + + + + + FFCK structure types ffck.structure.type diff --git a/ffck_commons/views/res_partner.xml b/ffck_commons/views/res_partner.xml index 3716955..55e62fa 100644 --- a/ffck_commons/views/res_partner.xml +++ b/ffck_commons/views/res_partner.xml @@ -28,14 +28,20 @@ - + - + + + + + + + {'invisible': [('is_company','=',True)]} + @@ -62,11 +71,9 @@ 30 - - - + @@ -95,7 +102,6 @@ - @@ -105,6 +111,26 @@ + + res.partner.view.search.inherit + res.partner + + 30 + + + + + + + + + + + + + + @@ -115,42 +141,11 @@ 'search_default_state_groupby': 1} - - Persons - ir.actions.act_window - res.partner - tree,kanban,form,activity - + {'default_is_company': False, 'search_default_type_person':1, 'search_default_ffck_network':1, 'search_default_by_age_range': 1} - - - Create a Contact in your address book - - - Odoo helps you track all activities related to your contacts. - - - - - - kanban - - - - - - tree - - - - - - form - - @@ -159,14 +154,8 @@ Structures - - - + + 4 @@ -176,9 +165,4 @@ parent="contacts.res_partner_menu_config" sequence="4" /> - - - 4 - - \ No newline at end of file
- Create a Contact in your address book -
- Odoo helps you track all activities related to your contacts. -