Browse Source

[IMP] ffck_commons partner fields + [I18N]

16.0
RemiFr82 7 months ago
parent
commit
cc71138b38
  1. 2
      ffck_commons/__init__.py
  2. 3
      ffck_commons/__manifest__.py
  3. 7
      ffck_commons/data/ffck_structure_type.xml
  4. 26
      ffck_commons/data/res_partner.xml
  5. 201
      ffck_commons/i18n/fr.po
  6. 2
      ffck_commons/models/__init__.py
  7. 2
      ffck_commons/models/ffck_structure_type.py
  8. 52
      ffck_commons/models/res_partner.py
  9. 3
      ffck_commons/security/ir.model.access.csv
  10. 19
      ffck_commons/security/ir_rule.xml
  11. 15
      ffck_commons/security/res_groups.xml
  12. 33
      ffck_commons/views/res_partner.xml

2
ffck_commons/__init__.py

@ -0,0 +1,2 @@
# -*- coding: utf-8 -*-
from . import models

3
ffck_commons/__manifest__.py

@ -11,6 +11,7 @@
"category": "Technical", "category": "Technical",
"depends": [ "depends": [
"base", "base",
"l10n_fr_association",
"partner_contact_email2", "partner_contact_email2",
"partner_contact_phones2", "partner_contact_phones2",
"partner_firstname", "partner_firstname",
@ -26,7 +27,7 @@
"data/ffck_structure_type.xml", "data/ffck_structure_type.xml",
"data/res_partner.xml", "data/res_partner.xml",
# Security # Security
# 'security/res_groups.xml',
"security/ir.model.access.csv",
# Views # Views
"views/res_partner.xml", "views/res_partner.xml",
# Wizards # Wizards

7
ffck_commons/data/ffck_structure_type.xml

@ -12,38 +12,43 @@
<field name="name">CRCK</field> <field name="name">CRCK</field>
<field name="short">CRCK</field> <field name="short">CRCK</field>
<field name="scale">reg</field> <field name="scale">reg</field>
<field name="parent_id" ref="ffck_structure_type_ffck" />
</record> </record>
<record id="ffck_structure_type_cdck" model="ffck.structure.type"> <record id="ffck_structure_type_cdck" model="ffck.structure.type">
<field name="name">CDCK</field> <field name="name">CDCK</field>
<field name="short">CDCK</field> <field name="short">CDCK</field>
<field name="scale">dep</field> <field name="scale">dep</field>
<field name="parent_id" ref="ffck_structure_type_crck" />
</record> </record>
<record id="ffck_structure_type_club" model="ffck.structure.type"> <record id="ffck_structure_type_club" model="ffck.structure.type">
<field name="name">Affiliate member</field> <field name="name">Affiliate member</field>
<field name="short">CLUB</field> <field name="short">CLUB</field>
<field name="scale">loc</field> <field name="scale">loc</field>
<field name="parent_id" ref="ffck_structure_type_cdck" />
</record> </record>
<record id="ffck_structure_type_agra" model="ffck.structure.type" forcecreate="0"> <record id="ffck_structure_type_agra" model="ffck.structure.type" forcecreate="0">
<field name="name">Type A agreed member</field> <field name="name">Type A agreed member</field>
<field name="short">AGRA</field> <field name="short">AGRA</field>
<field name="scale">loc</field> <field name="scale">loc</field>
<field name="parent_id" ref="ffck_structure_type_cdck" />
</record> </record>
<record id="ffck_structure_type_agrb" model="ffck.structure.type" forcecreate="0"> <record id="ffck_structure_type_agrb" model="ffck.structure.type" forcecreate="0">
<field name="name">Type B agreed member</field> <field name="name">Type B agreed member</field>
<field name="short">AGRB</field> <field name="short">AGRB</field>
<field name="scale">loc</field> <field name="scale">loc</field>
<field name="parent_id" ref="ffck_structure_type_cdck" />
</record> </record>
<record id="ffck_structure_type_conv" model="ffck.structure.type" forcecreate="0"> <record id="ffck_structure_type_conv" model="ffck.structure.type" forcecreate="0">
<field name="name">Conventioned member</field> <field name="name">Conventioned member</field>
<field name="short">CONV</field> <field name="short">CONV</field>
<field name="scale">loc</field> <field name="scale">loc</field>
<field name="parent_id" ref="ffck_structure_type_cdck" />
</record> </record>
</data> </data>
</odoo> </odoo>

26
ffck_commons/data/res_partner.xml

@ -2,18 +2,26 @@
<odoo> <odoo>
<data noupdate="1"> <data noupdate="1">
<record id="res_partner_ffck" model="res.partner" forcecreate="0">
<record id="res_partner_ffck" model="res.partner">
<field name="name">Fédération Française Canoë-Kayak et Sports de Pagaie</field> <field name="name">Fédération Française Canoë-Kayak et Sports de Pagaie</field>
<field name="is_company" eval="True" /> <field name="is_company" eval="True" />
<field name="street"></field>
<field name="street2"></field>
<field name="zip"></field>
<field name="city"></field>
<field name="association" eval="True" />
<field name="street">Stade nautique olympique d’Ile-de-France</field>
<field name="street2">Route de Torcy</field>
<field name="zip">77360</field>
<field name="city">VAIRES SUR MARNE</field>
<field name="country_id" ref="base.fr" /> <field name="country_id" ref="base.fr" />
<field name="vat"></field>
<field name="phone"></field>
<field name="email"></field>
<field name="website"></field>
<field name="vat">FR08785724378</field>
<field name="phone">+33 1 45 11 08 50</field>
<field name="email">ffck@ffck.org</field>
<field name="website">https://ffck.org</field>
<field name="ref">FFCK</field>
<field name="company_registry">W941001049</field>
<field name="siret">78572437800050</field>
<field name="ffck_network" eval="True" />
<field name="partner_code">0</field>
<field name="partner_scale">nat</field>
<field name="ffck_structure_type_id" ref="ffck_structure_type_ffck" />
</record> </record>
</data> </data>

201
ffck_commons/i18n/fr.po

@ -0,0 +1,201 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * ffck_commons
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 16.0-20230613\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2024-05-26 13:55+0000\n"
"PO-Revision-Date: 2024-05-26 13:55+0000\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: ffck_commons
#: model:ir.model.fields,field_description:ffck_commons.field_ffck_structure_type__active
msgid "Active"
msgstr "Actif"
#. module: ffck_commons
#: model:ir.model.fields,field_description:ffck_commons.field_res_partner__cdck_partner_id
#: model:ir.model.fields,field_description:ffck_commons.field_res_users__cdck_partner_id
msgid "CDCK partner"
msgstr "CDCK"
#. module: ffck_commons
#: model:ir.model.fields,field_description:ffck_commons.field_res_partner__crck_partner_id
#: model:ir.model.fields,field_description:ffck_commons.field_res_users__crck_partner_id
msgid "CRCK partner"
msgstr "CRCK"
#. module: ffck_commons
#: model:ir.model,name:ffck_commons.model_res_partner
msgid "Contact"
msgstr ""
#. module: ffck_commons
#: 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_structure_type__create_date
msgid "Created on"
msgstr "Créé le"
#. module: ffck_commons
#: model:ir.model.fields.selection,name:ffck_commons.selection__ffck_structure_type__scale__dep
#: model:ir.model.fields.selection,name:ffck_commons.selection__res_partner__partner_scale__dep
msgid "Departmental"
msgstr "Départementale"
#. module: ffck_commons
#: model:ir.model.fields,field_description:ffck_commons.field_ffck_structure_type__display_name
msgid "Display Name"
msgstr "Nom d'affichage"
#. 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
#: model_terms:ir.ui.view,arch_db:ffck_commons.view_partner_form_inherit_base
msgid "FFCK"
msgstr ""
#. module: ffck_commons
#: model:ir.model.fields,field_description:ffck_commons.field_res_partner__cdck_partner_code
#: model:ir.model.fields,field_description:ffck_commons.field_res_partner__crck_partner_code
#: model:ir.model.fields,field_description:ffck_commons.field_res_partner__partner_code
#: model:ir.model.fields,field_description:ffck_commons.field_res_users__cdck_partner_code
#: model:ir.model.fields,field_description:ffck_commons.field_res_users__crck_partner_code
#: model:ir.model.fields,field_description:ffck_commons.field_res_users__partner_code
msgid "FFCK code"
msgstr "Code FFCK"
#. 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
msgid "FFCK network"
msgstr "Réseau FFCK"
#. module: ffck_commons
#: model:ir.model.fields,field_description:ffck_commons.field_res_partner__ffck_partner_id
#: model:ir.model.fields,field_description:ffck_commons.field_res_users__ffck_partner_id
msgid "FFCK partner"
msgstr "FFCK"
#. module: ffck_commons
#: model:ir.model,name:ffck_commons.model_ffck_structure_type
msgid "FFCK structure type"
msgstr "Type de structure"
#. module: ffck_commons
#: model:ir.model.fields,field_description:ffck_commons.field_ffck_structure_type__id
msgid "ID"
msgstr ""
#. module: ffck_commons
#: model:ir.model.fields,field_description:ffck_commons.field_ffck_structure_type____last_update
msgid "Last Modified on"
msgstr "Dernière modification le"
#. module: ffck_commons
#: 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_structure_type__write_date
msgid "Last Updated on"
msgstr "Dernière mise à jour le"
#. 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.selection,name:ffck_commons.selection__ffck_structure_type__scale__lic
#: model:ir.model.fields.selection,name:ffck_commons.selection__res_partner__partner_scale__lic
msgid "Licensee"
msgstr "Licencié"
#. module: ffck_commons
#: model_terms:ir.ui.view,arch_db:ffck_commons.view_partner_form_inherit_base
msgid "Licensee information"
msgstr "Informations licencié"
#. module: ffck_commons
#: model:ir.model.fields.selection,name:ffck_commons.selection__ffck_structure_type__scale__loc
#: model:ir.model.fields.selection,name:ffck_commons.selection__res_partner__partner_scale__loc
msgid "Local"
msgstr "Locale"
#. module: ffck_commons
#: model:ir.model.fields,field_description:ffck_commons.field_ffck_structure_type__name
msgid "Name"
msgstr "Nom"
#. module: ffck_commons
#: model:ir.model.fields.selection,name:ffck_commons.selection__ffck_structure_type__scale__nat
#: model:ir.model.fields.selection,name:ffck_commons.selection__res_partner__partner_scale__nat
msgid "National"
msgstr "Nationale"
#. module: ffck_commons
#: model_terms:ir.ui.view,arch_db:ffck_commons.view_partner_form_inherit_base
msgid "Network"
msgstr "Réseau fédéral"
#. module: ffck_commons
#: model:ir.model.fields,field_description:ffck_commons.field_ffck_structure_type__parent_id
msgid "Parent"
msgstr ""
#. module: ffck_commons
#: model:ir.model.fields.selection,name:ffck_commons.selection__ffck_structure_type__scale__reg
#: model:ir.model.fields.selection,name:ffck_commons.selection__res_partner__partner_scale__reg
msgid "Regional"
msgstr "Régionale"
#. module: ffck_commons
#: 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
msgid "Scale"
msgstr "Échelle"
#. module: ffck_commons
#: 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"
msgstr "Code structure"
#. module: ffck_commons
#: model_terms:ir.ui.view,arch_db:ffck_commons.view_partner_form_inherit_base
msgid "Structure dates"
msgstr "Dates de la structure"
#. module: ffck_commons
#: model_terms:ir.ui.view,arch_db:ffck_commons.view_partner_form_inherit_base
msgid "Structure information"
msgstr "Infos de la structure"
#. module: ffck_commons
#: model:ir.model.fields,field_description:ffck_commons.field_res_partner__ffck_structure_type_id
#: model:ir.model.fields,field_description:ffck_commons.field_res_users__ffck_structure_type_id
msgid "Structure type"
msgstr "Type de structure"

2
ffck_commons/models/__init__.py

@ -1 +1,3 @@
# -*- coding: utf-8 -*-
from . import ffck_structure_type
from . import res_partner from . import res_partner

2
ffck_commons/models/ffck_structure_type.py

@ -11,4 +11,4 @@ class FfckStructureType(models.Model):
short = fields.Char("Short", required=True, index=True) short = fields.Char("Short", required=True, index=True)
scale = fields.Selection(SCALES, string="Scale", required=True) scale = fields.Selection(SCALES, string="Scale", required=True)
active = fields.Boolean(string="Active", default=True) active = fields.Boolean(string="Active", default=True)
parent_id = fields.Many2one("ffck.structure.type", string="parent")
parent_id = fields.Many2one(comodel_name="ffck.structure.type", string="Parent")

52
ffck_commons/models/res_partner.py

@ -1,17 +1,5 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
from odoo import models, fields, api from odoo import models, fields, api
from odoo.osv.expression import OR, AND
# STRUCTURE_TYPES = [
# ('ffck', 'Federal'),
# ('crck', 'Region'),
# ('cdck', 'Department'),
# ('club', 'Affiliate'),
# ('agra', 'Agreement A'),
# ('agrb', 'Agreement B'),
# ('conv', 'Convention'),
# ('asso', 'Associated'),
# ]
SCALES = [ SCALES = [
("nat", "National"), ("nat", "National"),
@ -27,7 +15,7 @@ class ResPartner(models.Model):
@api.model @api.model
def _get_ffck_partner(self): def _get_ffck_partner(self):
ffck = self.env.ref("ffck_commons.ffck_partner")
ffck = self.env.ref("ffck_commons.res_partner_ffck", raise_if_not_found=False)
main = self.env.ref("base.main_partner") main = self.env.ref("base.main_partner")
if main.ref == "FFCK": if main.ref == "FFCK":
if ffck.active: if ffck.active:
@ -37,8 +25,6 @@ class ResPartner(models.Model):
return ffck return ffck
# Partner fields # Partner fields
structure_create_date = fields.Date("Structure creation")
# FFCK fields
ffck_network = fields.Boolean(string="FFCK network") ffck_network = fields.Boolean(string="FFCK network")
first_membership_date = fields.Date("Structure 1st membership") first_membership_date = fields.Date("Structure 1st membership")
# Structure typing # Structure typing
@ -46,29 +32,35 @@ class ResPartner(models.Model):
selection=SCALES, selection=SCALES,
string="Scale", string="Scale",
) )
ffck_type_id = fields.Many2one(
ffck_structure_type_id = fields.Many2one(
comodel_name="ffck.structure.type", string="Structure type" comodel_name="ffck.structure.type", string="Structure type"
) )
# structure_type = fields.Selection(
# selection=STRUCTURE_TYPES,
# string="Structure",
# )
partner_code = fields.Char(string="FFCK code", size=6, index=True)
# partner_code_editable = fields.Boolean(string="FFCK code editable", compute="_can_edit_partner_code")
# FFCK
ffck_partner_id = fields.Many2one( ffck_partner_id = fields.Many2one(
"res.partner", "res.partner",
string="FFCK partner", string="FFCK partner",
default=_get_ffck_partner, default=_get_ffck_partner,
ondelete="restrict", ondelete="restrict",
) )
ffck_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( crck_partner_id = fields.Many2one(
"res.partner", string="CRCK partner", index=True, ondelete="restrict"
"res.partner",
string="CRCK partner",
index=True,
ondelete="restrict",
) )
crck_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( cdck_partner_id = fields.Many2one(
"res.partner", string="CDCK partner", index=True, ondelete="restrict"
"res.partner",
string="CDCK partner",
index=True,
ondelete="restrict",
) )
cdck_code = fields.Char(related="cdck_partner_id.partner_code", store=True)
partner_code = fields.Char(string="FFCK code", size=6, index=True, readonly=True)
cdck_partner_code = fields.Char(related="cdck_partner_id.partner_code", store=True)
@api.model @api.model
def name_search(self, name="", args=None, operator="ilike", limit=100): def name_search(self, name="", args=None, operator="ilike", limit=100):
@ -112,7 +104,7 @@ class ResPartner(models.Model):
# ONCHANGES # ONCHANGES
@api.onchange("partner_code")
@api.onchange("partner_code", "company_type", "ffck_network")
def onchange_partner_code(self): def onchange_partner_code(self):
if self.ffck_network and self.company_type == "individual": if self.ffck_network and self.company_type == "individual":
code = self.partner_code code = self.partner_code
@ -121,11 +113,11 @@ class ResPartner(models.Model):
elif len(code) > 6: elif len(code) > 6:
self.update({"partner_code": code[:-6]}) self.update({"partner_code": code[:-6]})
@api.onchange("company_type", "partner_scale", "ffck_type_id")
@api.onchange("company_type", "partner_scale", "ffck_structure_type_id")
def onchange_comp_type(self): def onchange_comp_type(self):
if self.company_type == "individual": if self.company_type == "individual":
self.update({"partner_scale": "lic"}) self.update({"partner_scale": "lic"})
elif self.partner_scale == "lic": elif self.partner_scale == "lic":
self.update({"partner_scale": False}) self.update({"partner_scale": False})
elif self.ffck_type_id:
self.update({"partner_scale": self.ffck_type_id.scale})
elif self.ffck_structure_type_id:
self.update({"partner_scale": self.ffck_structure_type_id.scale})

3
ffck_commons/security/ir.model.access.csv

@ -0,0 +1,3 @@
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
access_ir_model_all,All ffck.structure.type,ffck_commons.model_ffck_structure_type,,1,0,0,0
access_ir_model_group_partner_manager,Partner manager ffck.structure.type,ffck_commons.model_ffck_structure_type,base.group_partner_manager,1,1,1,0

19
ffck_commons/security/ir_rule.xml

@ -0,0 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<!-- <data noupdate="1"> -->
<data>
<!-- ir.model -->
<!-- <record id="ir_rule_ir_model_res_group" model="ir.rule">
<field name="name"></field>
<field name="model_id" ref="module.model_ir_model" />
<field name="domain_force">[]</field>
<field name="groups" eval="[(4, ref('module.res_group'))]" />
<field name="perm_read" eval="True" />
<field name="perm_write" eval="True" />
<field name="perm_create" eval="False" />
<field name="perm_unlink" eval="False" />
</record> -->
</data>
</odoo>

15
ffck_commons/security/res_groups.xml

@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<!-- <record id="ir_module_category_application" model="ir.module.category">
<field name="name">Application</field>
<field name="sequence"></field>
</record> -->
<!-- <record id="res_group_name" model="res.groups">
<field name="name">Group name</field>
<field name="implied_ids" eval="[(4, ref('base.group_user'))]" />
<field name="category_id" ref="ir_module_category_proapn_membership" />
</record> -->
</odoo>

33
ffck_commons/views/res_partner.xml

@ -6,31 +6,38 @@
<field name="model">res.partner</field> <field name="model">res.partner</field>
<field name="inherit_id" ref="base.view_partner_form" /> <field name="inherit_id" ref="base.view_partner_form" />
<field name="arch" type="xml"> <field name="arch" type="xml">
<field name="company_type" position="after">
<h1 position="after">
<field name="ffck_network" /> <field name="ffck_network" />
<label for="ffck_network" /> <label for="ffck_network" />
</field>
<xpath expr="//notebook/page[1]" position="before">
<page name="ffck_info" string="FFCK Info" attrs="{'invisible':[('ffck_network','!=',True)]}">
</h1>
<xpath expr="//notebook/page[1]" position="after">
<page name="ffck" string="FFCK" attrs="{'invisible':[('ffck_network','!=',True)]}">
<group name="ffck_main"> <group name="ffck_main">
<group name="ffck_common">
<group name="ffck_common" class="o_label_nowrap">
<separator colspan="2" string="Licensee information" <separator colspan="2" string="Licensee information"
attrs="{'invisible':[('company_type','!=','individual')]}" />
attrs="{'invisible':[('is_company','=',True)]}" />
<separator colspan="2" string="Structure information" <separator colspan="2" string="Structure information"
attrs="{'invisible':[('company_type','!=','company')]}" />
<field name="partner_code" />
<field name="partner_scale" attrs="{'invisible': [('company_type','=','individual')]}" />
<field name="ffck_type_id" widget="selection" attrs="{'invisible': [('company_type','=','individual')]}" />
attrs="{'invisible':[('is_company','=',False)]}" />
<label for="partner_code" string="License code"
attrs="{'invisible': [('is_company','=',True)]}" />
<label for="partner_code" string="Structure code"
attrs="{'invisible': [('is_company','=',False)]}" />
<field name="partner_code" nolabel="1" />
<!-- <field name="partner_code" nolabel="1" attrs="{'readonly':[('partner_code_editable','=',False)]}" />
<field name="partner_code_editable" invisible="1" /> -->
<field name="partner_scale" attrs="{'invisible': [('is_company','=',False)]}" />
<field name="ffck_structure_type_id" widget="selection"
attrs="{'invisible': [('is_company','=',False)]}" />
</group> </group>
<group name="ffck_network" string="Network" attrs="{'invisible': [('partner_scale', '=', 'lic')]}">
<group name="ffck_network" string="Network" class="o_label_nowrap"
attrs="{'invisible': [('partner_scale', '=', 'lic')]}">
<field name="ffck_partner_id" /> <field name="ffck_partner_id" />
<field name="crck_partner_id" attrs="{'invisible': [('partner_scale', '=', 'nat')]}" /> <field name="crck_partner_id" attrs="{'invisible': [('partner_scale', '=', 'nat')]}" />
<field name="cdck_partner_id" attrs="{'invisible': [('partner_scale', 'in', ['nat', 'reg'])]}" /> <field name="cdck_partner_id" attrs="{'invisible': [('partner_scale', 'in', ['nat', 'reg'])]}" />
</group> </group>
</group> </group>
<group name="ffck_data">
<group name="ffck_membership">
<group string="Structure dates"> <group string="Structure dates">
<field name="structure_create_date" />
<field name="first_membership_date" /> <field name="first_membership_date" />
</group> </group>
</group> </group>

Loading…
Cancel
Save