Browse Source

[ADD] age range dependency + [REF] partner form + [I18N]

16.0
RemiFr82 7 months ago
parent
commit
8fc9006c91
  1. 2
      ffck_commons/__manifest__.py
  2. 78
      ffck_commons/data/res_partner_age_range.xml
  3. 96
      ffck_commons/i18n/fr.po
  4. 3
      ffck_commons/models/__init__.py
  5. 304
      ffck_commons/models/res_partner.py
  6. 12
      ffck_commons/models/res_partner_age_range.py
  7. 94
      ffck_commons/views/res_partner.xml

2
ffck_commons/__manifest__.py

@ -15,6 +15,7 @@
"l10n_fr_association", "l10n_fr_association",
"partner_contact_age_range", "partner_contact_age_range",
"partner_contact_birthdate", "partner_contact_birthdate",
"partner_contact_birthplace",
"partner_contact_gender", "partner_contact_gender",
"partner_contact_email2", "partner_contact_email2",
"partner_contact_nationality", "partner_contact_nationality",
@ -26,6 +27,7 @@
# Base data # Base data
"data/ffck_structure_type.xml", "data/ffck_structure_type.xml",
"data/res_partner.xml", "data/res_partner.xml",
"data/res_partner_age_range.xml",
# Security # Security
"security/ir.model.access.csv", "security/ir.model.access.csv",
# Views # Views

78
ffck_commons/data/res_partner_age_range.xml

@ -0,0 +1,78 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<data noupdate="1">
<record id="age_range_microbe" model="res.partner.age.range">
<field name="name">Microbe</field>
<field name="age_from">0</field>
<field name="age_to">8</field>
</record>
<record id="age_range_poussin" model="res.partner.age.range">
<field name="name">Poussin</field>
<field name="age_from">9</field>
<field name="age_to">10</field>
</record>
<record id="age_range_benjamin" model="res.partner.age.range">
<field name="name">Benjamin</field>
<field name="age_from">11</field>
<field name="age_to">12</field>
</record>
<record id="age_range_minime" model="res.partner.age.range">
<field name="name">Minime</field>
<field name="age_from">13</field>
<field name="age_to">14</field>
</record>
<record id="age_range_cadet" model="res.partner.age.range">
<field name="name">Cadet</field>
<field name="age_from">15</field>
<field name="age_to">16</field>
</record>
<record id="age_range_junior" model="res.partner.age.range">
<field name="name">Junior</field>
<field name="age_from">17</field>
<field name="age_to">18</field>
</record>
<record id="age_range_senior" model="res.partner.age.range">
<field name="name">Sénior</field>
<field name="age_from">19</field>
<field name="age_to">34</field>
</record>
<record id="age_range_veteran1" model="res.partner.age.range">
<field name="name">Vétéran 1</field>
<field name="age_from">35</field>
<field name="age_to">44</field>
</record>
<record id="age_range_veteran2" model="res.partner.age.range">
<field name="name">Vétéran 2</field>
<field name="age_from">45</field>
<field name="age_to">54</field>
</record>
<record id="age_range_veteran3" model="res.partner.age.range">
<field name="name">Vétéran 3</field>
<field name="age_from">55</field>
<field name="age_to">64</field>
</record>
<record id="age_range_veteran4" model="res.partner.age.range">
<field name="name">Vétéran 4</field>
<field name="age_from">65</field>
<field name="age_to">74</field>
</record>
<record id="age_range_veteran5" model="res.partner.age.range">
<field name="name">Vétéran 5</field>
<field name="age_from">75</field>
<field name="age_to">100</field>
</record>
</data>
</odoo>

96
ffck_commons/i18n/fr.po

@ -6,8 +6,8 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: Odoo Server 16.0-20230613\n" "Project-Id-Version: Odoo Server 16.0-20230613\n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2024-05-27 16:36+0000\n"
"PO-Revision-Date: 2024-05-27 16:36+0000\n"
"POT-Creation-Date: 2024-05-27 21:44+0000\n"
"PO-Revision-Date: 2024-05-27 21:44+0000\n"
"Last-Translator: \n" "Last-Translator: \n"
"Language-Team: \n" "Language-Team: \n"
"MIME-Version: 1.0\n" "MIME-Version: 1.0\n"
@ -17,6 +17,9 @@ msgstr ""
#. module: ffck_commons #. module: ffck_commons
#: model:ir.model.fields,field_description:ffck_commons.field_ffck_structure_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
#: model_terms:ir.ui.view,arch_db:ffck_commons.view_res_partner_filter_inherit_base
msgid "Active" msgid "Active"
msgstr "Actif" msgstr "Actif"
@ -25,6 +28,16 @@ msgstr "Actif"
msgid "Affiliate member" msgid "Affiliate member"
msgstr "Membre affilié" msgstr "Membre affilié"
#. module: ffck_commons
#: model_terms:ir.ui.view,arch_db:ffck_commons.view_res_partner_filter_inherit_base
msgid "Age range"
msgstr "Tranche d'âges"
#. module: ffck_commons
#: model:res.partner.age.range,name:ffck_commons.age_range_benjamin
msgid "Benjamin"
msgstr ""
#. module: ffck_commons #. 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_partner__cdck_partner_id
#: model:ir.model.fields,field_description:ffck_commons.field_res_users__cdck_partner_id #: model:ir.model.fields,field_description:ffck_commons.field_res_users__cdck_partner_id
@ -37,6 +50,11 @@ msgstr "CDCK"
msgid "CRCK partner" msgid "CRCK partner"
msgstr "CRCK" msgstr "CRCK"
#. module: ffck_commons
#: model:res.partner.age.range,name:ffck_commons.age_range_cadet
msgid "Cadet"
msgstr ""
#. module: ffck_commons #. module: ffck_commons
#: model:ir.model,name:ffck_commons.model_res_partner #: model:ir.model,name:ffck_commons.model_res_partner
msgid "Contact" msgid "Contact"
@ -47,6 +65,11 @@ msgstr ""
msgid "Conventioned member" msgid "Conventioned member"
msgstr "Membre conventionné" msgstr "Membre conventionné"
#. module: ffck_commons
#: model_terms:ir.actions.act_window,help:ffck_commons.action_persons
msgid "Create a Contact in your address book"
msgstr "Créer un contact dans votre annuaire"
#. module: ffck_commons #. module: ffck_commons
#: model:ir.model.fields,field_description:ffck_commons.field_ffck_structure_type__create_uid #: model:ir.model.fields,field_description:ffck_commons.field_ffck_structure_type__create_uid
msgid "Created by" msgid "Created by"
@ -108,6 +131,7 @@ msgstr "Code FFCK éditable"
#. module: ffck_commons #. 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_partner__ffck_network
#: model:ir.model.fields,field_description:ffck_commons.field_res_users__ffck_network #: model:ir.model.fields,field_description:ffck_commons.field_res_users__ffck_network
#: model_terms:ir.ui.view,arch_db:ffck_commons.view_res_partner_filter_inherit_base
msgid "FFCK network" msgid "FFCK network"
msgstr "Réseau FFCK" msgstr "Réseau FFCK"
@ -154,6 +178,11 @@ msgstr "Hiérarchie"
msgid "ID" msgid "ID"
msgstr "" msgstr ""
#. module: ffck_commons
#: model:res.partner.age.range,name:ffck_commons.age_range_junior
msgid "Junior"
msgstr ""
#. module: ffck_commons #. module: ffck_commons
#: model:ir.model.fields,field_description:ffck_commons.field_ffck_structure_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 #: model:ir.model.fields,field_description:ffck_commons.field_res_partner_hierarchy____last_update
@ -204,8 +233,24 @@ msgstr "Structure locale"
msgid "Local structures" msgid "Local structures"
msgstr "Structures locales" msgstr "Structures locales"
#. module: ffck_commons
#: model_terms:ir.ui.view,arch_db:ffck_commons.view_partner_form_inherit_base
msgid "Lock partner code"
msgstr "Verrouiller le code"
#. module: ffck_commons
#: model:res.partner.age.range,name:ffck_commons.age_range_microbe
msgid "Microbe"
msgstr ""
#. module: ffck_commons
#: model:res.partner.age.range,name:ffck_commons.age_range_minime
msgid "Minime"
msgstr ""
#. module: ffck_commons #. module: ffck_commons
#: model:ir.model.fields,field_description:ffck_commons.field_ffck_structure_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 #: model:ir.model.fields,field_description:ffck_commons.field_res_partner_hierarchy__name
msgid "Name" msgid "Name"
msgstr "Nom" msgstr "Nom"
@ -221,12 +266,22 @@ msgstr "Nationale"
msgid "Network" msgid "Network"
msgstr "Réseau fédéral" msgstr "Réseau fédéral"
#. 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."
msgstr "Odoo vous aide à suivre les activités liées à vos contacts"
#. module: ffck_commons #. 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_ffck_structure_type__parent_id
#: model:ir.model.fields,field_description:ffck_commons.field_res_partner_hierarchy__parent_id #: model:ir.model.fields,field_description:ffck_commons.field_res_partner_hierarchy__parent_id
msgid "Parent" msgid "Parent"
msgstr "" msgstr ""
#. module: ffck_commons
#: model:ir.model,name:ffck_commons.model_res_partner_age_range
msgid "Partner Age Range"
msgstr "Tranche d'âges du partenaire"
#. module: ffck_commons #. 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.view_res_partner_filter_inherit_base
msgid "Partner scale" msgid "Partner scale"
@ -238,10 +293,17 @@ msgid "Partners hierarchy"
msgstr "Hiérarchie des partenaires" msgstr "Hiérarchie des partenaires"
#. module: ffck_commons #. 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 #: model_terms:ir.ui.view,arch_db:ffck_commons.view_res_partner_filter_inherit_base
msgid "Persons" msgid "Persons"
msgstr "Personnes" msgstr "Personnes"
#. module: ffck_commons
#: model:res.partner.age.range,name:ffck_commons.age_range_poussin
msgid "Poussin"
msgstr ""
#. module: ffck_commons #. 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__ffck_structure_type__scale__2
#: model:ir.model.fields.selection,name:ffck_commons.selection__res_partner__partner_scale__2 #: model:ir.model.fields.selection,name:ffck_commons.selection__res_partner__partner_scale__2
@ -266,6 +328,11 @@ msgstr "Comité Régional"
msgid "Scale" msgid "Scale"
msgstr "Échelle" msgstr "Échelle"
#. module: ffck_commons
#: model:res.partner.age.range,name:ffck_commons.age_range_senior
msgid "Senior"
msgstr ""
#. module: ffck_commons #. module: ffck_commons
#: model:ir.model.fields,field_description:ffck_commons.field_ffck_structure_type__short #: model:ir.model.fields,field_description:ffck_commons.field_ffck_structure_type__short
msgid "Short" msgid "Short"
@ -318,3 +385,28 @@ msgstr "Membre agréé Type A"
#: model:ffck.structure.type,name:ffck_commons.ffck_structure_type_agrb #: model:ffck.structure.type,name:ffck_commons.ffck_structure_type_agrb
msgid "Type B agreed member" msgid "Type B agreed member"
msgstr "Membre agréé Type B" msgstr "Membre agréé Type B"
#. module: ffck_commons
#: model:res.partner.age.range,name:ffck_commons.age_range_veteran1
msgid "Vétéran 1"
msgstr ""
#. module: ffck_commons
#: model:res.partner.age.range,name:ffck_commons.age_range_veteran2
msgid "Vétéran 2"
msgstr ""
#. module: ffck_commons
#: model:res.partner.age.range,name:ffck_commons.age_range_veteran3
msgid "Vétéran 3"
msgstr ""
#. module: ffck_commons
#: model:res.partner.age.range,name:ffck_commons.age_range_veteran4
msgid "Vétéran 4"
msgstr ""
#. module: ffck_commons
#: model:res.partner.age.range,name:ffck_commons.age_range_veteran5
msgid "Vétéran 5"
msgstr ""

3
ffck_commons/models/__init__.py

@ -1,4 +1,7 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
from . import ffck_structure_type from . import ffck_structure_type
from . import res_partner from . import res_partner
from . import res_partner_age_range
# IMPORT hierarchy AFTER res_partner
from . import res_partner_hierarchy from . import res_partner_hierarchy

304
ffck_commons/models/res_partner.py

@ -6,6 +6,7 @@ from .ffck_structure_type import SCALES
class ResPartner(models.Model): class ResPartner(models.Model):
_inherit = "res.partner" _inherit = "res.partner"
_rec_names_search = ["display_name", "ref", "partner_code", "email"]
# Partner fields # Partner fields
ffck_network = fields.Boolean(string="FFCK network") ffck_network = fields.Boolean(string="FFCK network")
@ -22,7 +23,9 @@ class ResPartner(models.Model):
string="Structure type", string="Structure type",
) )
partner_code = fields.Char(string="FFCK code", size=6, index=True) partner_code = fields.Char(string="FFCK code", size=6, index=True)
partner_code_editable = fields.Boolean(string="FFCK code editable", default=True)
partner_code_editable = fields.Boolean(
string="FFCK code editable", default=True, readonly=True
)
# FFCK # FFCK
ffck_partner_id = fields.Many2one( ffck_partner_id = fields.Many2one(
comodel_name="res.partner", comodel_name="res.partner",
@ -80,7 +83,7 @@ class ResPartner(models.Model):
domain=[("partner_scale", "=", "4")], domain=[("partner_scale", "=", "4")],
string="Local structures", string="Local structures",
) )
# Compute hierarchy for searchpanel
# Compute hierarchy for searchpanel TODO : move to standalone module
hierarchy_id = fields.Many2one( hierarchy_id = fields.Many2one(
comodel_name="res.partner.hierarchy", comodel_name="res.partner.hierarchy",
string="Hierarchy element", string="Hierarchy element",
@ -88,66 +91,54 @@ class ResPartner(models.Model):
store=True, store=True,
) )
@api.depends("ffck_network", "partner_scale", "partner_code")
@api.depends(
"ffck_network",
"partner_scale",
"partner_code",
"local_partner_id",
"cdck_partner_id",
"crck_partner_id",
"ffck_partner_id",
)
def _compute_partner_hierarchy(self): def _compute_partner_hierarchy(self):
for partner in self: for partner in self:
partner.hierarchy_id = ( partner.hierarchy_id = (
partner.id partner.id
if partner.ffck_network if partner.ffck_network
and int(partner.partner_scale) in range(1, 5)
and int(partner.partner_scale) in range(1, 4)
and partner.partner_code and partner.partner_code
else False
else partner.local_partner_id.id
or partner.cdck_partner_id.id
or partner.crck_partner_id.id
or partner.ffck_partner_id.id
) )
@api.model
def name_search(self, name="", args=None, operator="ilike", limit=100):
"""Allow searching by sequence code by default."""
# Do not add any domain when user just clicked on search widget
if not (name == "" and operator == "ilike"):
# The dangling | is needed to combine with the domain added by super()
args = OR(
[
[
"&",
("ffck_network", "=", True),
("partner_code", "=like", name + "%"),
],
args or [],
]
)
return super().name_search(name, args, operator, limit)
@api.depends("name", "ref", "partner_code")
def name_get(self):
result = []
ffck_partners = self.filtered("ffck_network")
others = self - ffck_partners
for record in ffck_partners:
code = record.partner_code
ref = record.ref
result.append(
(
record.id,
"{}{}{}".format(
code and code + " - " or "",
ref and record.is_company and ref + " - " or "",
super(ResPartner, record).name_get()[0][1],
),
)
)
result += super(ResPartner, others).name_get()
return result
# COMPUTES # COMPUTES
@api.depends("company_type", "ffck_structure_type_id")
@api.depends(
"is_company",
"ffck_network",
"ffck_structure_type_id",
"ffck_structure_type_id.scale",
)
def _get_partner_scale(self): def _get_partner_scale(self):
for partner in self:
if partner.company_type == "individual":
ffck_partners = self.filtered("ffck_network")
for partner in ffck_partners:
if not partner.is_company:
partner.partner_scale = "5" partner.partner_scale = "5"
else: else:
partner.partner_scale = partner.ffck_structure_type_id.scale
partner.partner_scale = (
partner.ffck_structure_type_id.scale
if partner.ffck_structure_type_id
else False
)
for partner in self - ffck_partners:
partner.partner_scale = False
def lock_partner_code(self):
self.write({"partner_code_editable": False})
@api.depends("ffck_network")
def _get_ffck_partner(self): def _get_ffck_partner(self):
ffck = self.env.ref("ffck_commons.res_partner_ffck", raise_if_not_found=False) 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")
@ -159,29 +150,39 @@ class ResPartner(models.Model):
else: else:
partner.ffck_partner_id = ffck partner.ffck_partner_id = ffck
@api.depends("state_id", "ffck_network", "partner_scale")
@api.depends(
"state_id",
"ffck_network",
"partner_scale",
"cdck_partner_id",
)
def _get_crck_partner(self): def _get_crck_partner(self):
states = self.mapped("state_id")
crck_ok = self.with_context(active_test=False).search(
[
("ffck_network", "=", True),
("partner_scale", "=", "2"),
("state_id", "in", states.ids),
]
)
crck_by_state = {crck.state_id: crck for crck in crck_ok}
states_ok = states & crck_ok.mapped("state_id")
concerned = self.filtered(
lambda rp: rp.ffck_network
and int(rp.partner_scale) >= 2
and rp.state_id in states_ok
)
for partner in concerned:
state = partner.state_id
partner.crck_partner_id = crck_by_state[state]
# treat unconcerned
for partner in self - concerned:
partner.crck_partner_id = False
cdck_ok = self.filtered("cdck_partner_id")
for partner in cdck_ok:
partner.crck_partner_id = partner.cdck_partner_id.crck_partner_id
todo = self - cdck_ok
if todo:
states = todo.mapped("state_id")
crck_ok = self.with_context(active_test=False).search(
[
("ffck_network", "=", True),
("partner_scale", "=", "2"),
("state_id", "in", states.ids),
]
)
states_ok = states & crck_ok.mapped("state_id")
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 rp.state_id in states_ok
)
for partner in concerned:
state = partner.state_id
partner.crck_partner_id = crck_by_state[state]
# treat unconcerned
for partner in todo - concerned:
partner.crck_partner_id = False
@api.depends( @api.depends(
"is_company", "is_company",
@ -189,56 +190,70 @@ class ResPartner(models.Model):
"partner_code", "partner_code",
"partner_scale", "partner_scale",
"local_partner_id", "local_partner_id",
"local_partner_id",
"local_partner_id.partner_code", "local_partner_id.partner_code",
"country_department_id", "country_department_id",
"country_department_id.code", "country_department_id.code",
) )
def _get_cdck_partner(self): def _get_cdck_partner(self):
structures = self.filtered(
lambda rp: rp.is_company
and rp.ffck_network
and rp.partner_code
and len(rp.partner_code) >= 2
and int(rp.partner_scale) in (3, 4)
)
licensees = self.filtered(
lambda rp: not rp.is_company
and rp.ffck_network
and int(rp.partner_scale) == 5
and (
rp.local_partner_id
and rp.local_partner_id.cdck_partner_id
or rp.country_department_id
local_ok = self.filtered("local_partner_id")
for partner in local_ok:
partner.cdck_partner_id = partner.local_partner_id.cdck_partner_id
todo = self - local_ok
if todo:
structures = todo.filtered(
lambda rp: rp.is_company
and rp.ffck_network
and rp.partner_code
and len(rp.partner_code) >= 2
and int(rp.partner_scale) in (3, 4)
)
licensees = todo.filtered(
lambda rp: not rp.is_company
and rp.ffck_network
and int(rp.partner_scale) == 5
and rp.country_department_id
) )
)
dept_codes = self.mapped(
lambda rp: rp.partner_code
and len(rp.partner_code) >= 2
and int(rp.partner_scale) in (3, 4)
and rp.partner_code[:2]
)
cdck_ok = self.with_context(active_test=False).search(
[
("ffck_network", "=", True),
("partner_scale", "=", "3"),
("partner_code", "in", ["{}00".format(code) for code in dept_codes]),
]
)
cdck_by_code = {cdck.partner_code[:2]: cdck for cdck in cdck_ok}
# Treat structures
for partner in structures:
partner.cdck_partner_id = cdck_by_code[partner.partner_code[:2]]
# Treat licensees
for partner in licensees:
dept = partner.country_department_id
local = partner.local_partner_id
local_cd = local.cdck_partner_id
partner.cdck_partner_id = (
local_cd if local and local_cd else cdck_by_code[dept.code]
dept_codes = todo.mapped(
lambda rp: rp.ffck_network
and (
rp.is_company
and rp.partner_code
and len(rp.partner_code) >= 2
and int(rp.partner_scale) in (3, 4)
and rp.partner_code[:2]
or not rp.is_company
and rp.country_department_id
and rp.country_department_id.code
)
)
cdck_ok = self.with_context(active_test=False).search(
[
("is_company", "=", True),
("ffck_network", "=", True),
("partner_scale", "=", "3"),
(
"partner_code",
"in",
["{}00".format(code) for code in dept_codes],
),
]
) )
# treat others
for partner in self - (structures | licensees):
partner.cdck_partner_id = False
cdck_by_code = {cdck.partner_code[:2]: cdck for cdck in cdck_ok}
# Treat structures
for partner in structures:
partner.cdck_partner_id = cdck_by_code[partner.partner_code[:2]]
# Treat licensees
for partner in licensees:
dept = partner.country_department_id
local = partner.local_partner_id
local_cd = local.cdck_partner_id
partner.cdck_partner_id = (
local_cd if local and local_cd else cdck_by_code[dept.code]
)
# treat others
for partner in todo - (structures | licensees):
partner.cdck_partner_id = False
@api.depends( @api.depends(
"ffck_network", "ffck_network",
@ -263,6 +278,59 @@ class ResPartner(models.Model):
else: else:
partner.ffck_parent_id = False partner.ffck_parent_id = False
# INHERITANCE
# @api.model
# def name_search(self, name="", args=None, operator="ilike", limit=100):
# """Allow searching by sequence code by default."""
# # Do not add any domain when user just clicked on search widget
# if not (name == "" and operator == "ilike"):
# # The dangling | is needed to combine with the domain added by super()
# args = OR(
# [
# [
# "&",
# ("ffck_network", "=", True),
# ("partner_code", "=like", name + "%"),
# ],
# args or [],
# ]
# )
# return super().name_search(name, args, operator, limit)
@api.depends(
"is_company",
"name",
"parent_id.display_name",
"type",
"company_name",
"commercial_company_name",
"ref",
"partner_code",
)
def _compute_display_name(self):
return super()._compute_display_name()
def name_get(self):
res = []
ffck_partners = self.filtered("ffck_network")
others = self - ffck_partners
for record in ffck_partners:
code = record.partner_code
ref = record.ref
res.append(
(
record.id,
"{}{}{}".format(
code and code + " - " or "",
ref and record.is_company and ref + " - " or "",
super(ResPartner, record).name_get()[0][1],
),
)
)
res += super(ResPartner, others).name_get()
return res
# ONCHANGES # ONCHANGES
@api.onchange("partner_code", "company_type", "ffck_network") @api.onchange("partner_code", "company_type", "ffck_network")
@ -276,8 +344,8 @@ class ResPartner(models.Model):
# CRUD # CRUD
@api.model_create_multi
def create(self, vals_list):
for vals in vals_list:
vals.update({"partner_code_editable": False})
return super().create(vals_list)
# @api.model_create_multi
# def create(self, vals_list):
# for vals in vals_list:
# vals.update({"partner_code_editable": False})
# return super().create(vals_list)

12
ffck_commons/models/res_partner_age_range.py

@ -0,0 +1,12 @@
# Copyright 2019-2020: Druidoo (<https://www.druidoo.io>)
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
from odoo import _, api, fields, models
from odoo.exceptions import ValidationError
class ResPartnerAgeRange(models.Model):
_inherit = "res.partner.age.range"
name = fields.Char(translate=True)
active = fields.Boolean(string="Active", default=True)

94
ffck_commons/views/res_partner.xml

@ -24,17 +24,18 @@
<label for="partner_code" string="Structure code" <label for="partner_code" string="Structure code"
attrs="{'invisible': [('is_company','=',False)]}" /> attrs="{'invisible': [('is_company','=',False)]}" />
<field name="partner_code" nolabel="1" <field name="partner_code" nolabel="1"
attrs="{'readonly':[('partner_code_editable','=',False)],'required':[('partner_code_editable','=',False)]}" />
attrs="{'readonly':[('partner_code_editable','=',False)],'required':[('ffck_network','=',True),('is_company','=',False),('partner_code_editable','=',False)]}" />
<field name="partner_code_editable" invisible="1" /> <field name="partner_code_editable" invisible="1" />
<!-- <field name="partner_code" groups="base.group_no_one" /> -->
<button type="object" name="lock_partner_code" string="Lock partner code" icon="fa-lock"
class="btn btn-warning oe_right" colspan="2" attrs="{'invisible':[('partner_code_editable','=',False)]}" />
<field name="hierarchy_id" readonly="1" groups="base.group_no_one" />
<field name="partner_scale" attrs="{'invisible': [('is_company','=',False)]}" /> <field name="partner_scale" attrs="{'invisible': [('is_company','=',False)]}" />
<field name="ffck_structure_type_id" widget="selection" <field name="ffck_structure_type_id" widget="selection"
attrs="{'invisible': [('is_company','=',False)]}" /> attrs="{'invisible': [('is_company','=',False)]}" />
<separator string="Structure dates" colspan="2" /> <separator string="Structure dates" colspan="2" />
<field name="first_membership_date" /> <field name="first_membership_date" />
</group> </group>
<group name="ffck_network" colspan="2" string="Network" class="o_label_nowrap"
attrs="{'invisible': [('partner_scale', '=', '5')]}">
<group name="ffck_network" colspan="2" string="Network" class="o_label_nowrap">
<field name="ffck_partner_id" attrs="{'invisible': [('partner_scale', 'in', ['1'])]}" /> <field name="ffck_partner_id" attrs="{'invisible': [('partner_scale', 'in', ['1'])]}" />
<label for="crck_partner_ids" attrs="{'invisible': [('partner_scale', '!=', '1')]}" colspan="2" /> <label for="crck_partner_ids" attrs="{'invisible': [('partner_scale', '!=', '1')]}" colspan="2" />
<field name="crck_partner_ids" attrs="{'invisible': [('partner_scale', '!=', '1')]}" mode="kanban" <field name="crck_partner_ids" attrs="{'invisible': [('partner_scale', '!=', '1')]}" mode="kanban"
@ -55,6 +56,21 @@
</field> </field>
</record> </record>
<record id="personal_information_form_inherit" model="ir.ui.view">
<field name="name">res.partner.form.inherit Birth place</field>
<field name="model">res.partner</field>
<field name="inherit_id" ref="partner_contact_personal_information_page.personal_information" />
<field name="priority">30</field>
<field name="arch" type="xml">
<field name="birthplace" position="after">
<field name="gender" widget="radio" options="{'horizontal': true}" />
</field>
<field name="age" position="after">
<field name="age_range_id" widget="selection" />
</field>
</field>
</record>
<record id="view_res_partner_filter_inherit_base" model="ir.ui.view"> <record id="view_res_partner_filter_inherit_base" model="ir.ui.view">
<field name="name">res.partner.view.search.inherit</field> <field name="name">res.partner.view.search.inherit</field>
<field name="model">res.partner</field> <field name="model">res.partner</field>
@ -67,6 +83,10 @@
<filter name="type_company" position="attributes"> <filter name="type_company" position="attributes">
<attribute name="string">Structures</attribute> <attribute name="string">Structures</attribute>
</filter> </filter>
<filter name="association" position="after">
<separator />
<filter name="ffck_network" string="FFCK network" domain="[('ffck_network', '=', True)]" />
</filter>
<filter name="inactive" position="after"> <filter name="inactive" position="after">
<filter name="active" string="Active" domain="[('active','=',True)]" /> <filter name="active" string="Active" domain="[('active','=',True)]" />
</filter> </filter>
@ -75,6 +95,7 @@
<filter name="partner_scale" string="Partner scale" domain="[]" context="{'group_by' : 'partner_scale'}" /> <filter name="partner_scale" string="Partner scale" domain="[]" context="{'group_by' : 'partner_scale'}" />
<filter name="ffck_structure_type" string="Structure type" <filter name="ffck_structure_type" string="Structure type"
context="{'group_by' : 'ffck_structure_type_id'}" /> context="{'group_by' : 'ffck_structure_type_id'}" />
<filter name="by_age_range" string="Age range" context="{'group_by': 'age_range_id'}" />
</group> </group>
<search position="inside"> <search position="inside">
<searchpanel> <searchpanel>
@ -84,6 +105,71 @@
</field> </field>
</record> </record>
<!-- ACTIONS -->
<record id="contacts.action_contacts" model="ir.actions.act_window">
<field name="name">Structures</field>
<field name="context">{'default_is_company': True,
'search_default_type_company':1,
'search_default_ffck_network':1,
'search_default_state_groupby': 1}</field>
</record>
<record id="action_persons" model="ir.actions.act_window">
<field name="name">Persons</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">res.partner</field>
<field name="view_mode">tree,kanban,form,activity</field>
<field name="search_view_id" ref="base.view_res_partner_filter" />
<field name="context">{'default_is_company': False,
'search_default_type_person':1,
'search_default_ffck_network':1,
'search_default_by_age_range': 1}</field>
<field name="help" type="html">
<p class="o_view_nocontent_smiling_face">
Create a Contact in your address book
</p>
<p>
Odoo helps you track all activities related to your contacts.
</p>
</field>
</record>
<record id="action_persons_view_kanban" model="ir.actions.act_window.view">
<field name="sequence" eval="0" />
<field name="view_mode">kanban</field>
<field name="view_id" ref="base.res_partner_kanban_view" />
<field name="act_window_id" ref="action_persons" />
</record>
<record id="action_persons_view_tree" model="ir.actions.act_window.view">
<field name="sequence" eval="1" />
<field name="view_mode">tree</field>
<field name="view_id" ref="base.view_partner_tree" />
<field name="act_window_id" ref="action_persons" />
</record>
<record id="action_persons_view_form" model="ir.actions.act_window.view">
<field name="sequence" eval="2" />
<field name="view_mode">form</field>
<field name="view_id" ref="base.view_partner_form" />
<field name="act_window_id" ref="action_persons" />
</record>
<!-- MENUS -->
<record id="contacts.res_partner_menu_contacts" model="ir.ui.menu">
<field name="name">Structures</field>
</record>
<menuitem
id="res_partner_menu_persons"
name="Persons"
action="action_persons"
parent="contacts.menu_contacts"
sequence="3" />
<record id="contacts.res_partner_menu_config" model="ir.ui.menu">
<field name="sequence">4</field>
</record>
<menuitem <menuitem
id="ffck_contacts_config_menu" id="ffck_contacts_config_menu"
name="FFCK params" name="FFCK params"

Loading…
Cancel
Save