Browse Source

[ADD] is_french on partners and countries + views priority

16.0
RemiFr82 7 months ago
parent
commit
d223a56389
  1. 1
      l10n_fr_association/__init__.py
  2. 3
      l10n_fr_association/__manifest__.py
  3. 40
      l10n_fr_association/hooks.py
  4. 39
      l10n_fr_association/i18n/fr.po
  5. 1
      l10n_fr_association/models/__init__.py
  6. 10
      l10n_fr_association/models/res_country.py
  7. 16
      l10n_fr_association/models/res_partner.py
  8. 30
      l10n_fr_association/views/res_country.xml
  9. 5
      l10n_fr_association/views/res_partner.xml
  10. 2
      l10n_fr_association/views/res_partner_relation_type.xml

1
l10n_fr_association/__init__.py

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

3
l10n_fr_association/__manifest__.py

@ -27,6 +27,7 @@
# Security
"security/ir.model.access.csv",
# Views
"views/res_country.xml",
"views/res_partner.xml",
"views/res_partner_relation_instance.xml",
"views/res_partner_relation_type.xml",
@ -41,6 +42,6 @@
"installable": True,
"maintainer": "RemiFr82",
"pre_init_hook": "",
"post_init_hook": "",
"post_init_hook": "post_init_hook",
"uninstall_hook": "",
}

40
l10n_fr_association/hooks.py

@ -0,0 +1,40 @@
import logging
from odoo.api import Environment, SUPERUSER_ID
_logger = logging.getLogger(__name__)
# def pre_init_hook(cr, registry):
# env = Environment(cr, SUPERUSER_ID, {})
# _logger.info("Pre init hook")
def post_init_hook(cr, registry):
env = Environment(cr, SUPERUSER_ID, {})
env["res.country"].search(
[
(
"code",
"in",
(
"FR",
"GP",
"MQ",
"GF",
"RE",
"YT",
),
)
]
).write(
{
"is_french": True,
}
)
_logger.info("\n#####\nPost init hook for french associations passed...\n#####\n")
# def uninstall_hook(cr, registry):
# env = Environment(cr, SUPERUSER_ID, {})
# _logger.info("Uninstall hook")

39
l10n_fr_association/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-26 22:57+0000\n"
"PO-Revision-Date: 2024-05-26 22:57+0000\n"
"POT-Creation-Date: 2024-05-27 16:13+0000\n"
"PO-Revision-Date: 2024-05-27 16:13+0000\n"
"Last-Translator: \n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
@ -96,6 +96,16 @@ msgstr "C.A."
msgid "Councile"
msgstr "Conseil d'Administration"
#. module: l10n_fr_association
#: model:ir.model,name:l10n_fr_association.model_res_country
msgid "Country"
msgstr "Pays"
#. module: l10n_fr_association
#: model_terms:ir.ui.view,arch_db:l10n_fr_association.res_country_view_search
msgid "Country Group"
msgstr "Groupe de pays"
#. module: l10n_fr_association
#: model:ir.model.fields,field_description:l10n_fr_association.field_res_partner_relation_instance__create_uid
msgid "Created by"
@ -139,11 +149,31 @@ msgstr "Employé"
msgid "Error ! You cannot create recursive instances."
msgstr "Erreur ! vous ne pouvez pas créer des instances recursives."
#. module: l10n_fr_association
#: model_terms:ir.ui.view,arch_db:l10n_fr_association.res_country_view_search
msgid "Europe"
msgstr ""
#. module: l10n_fr_association
#: model_terms:ir.ui.view,arch_db:l10n_fr_association.view_partner_form_inherit_base
msgid "Foundation"
msgstr "Fondation"
#. module: l10n_fr_association
#: model_terms:ir.ui.view,arch_db:l10n_fr_association.view_res_partner_filter_inherit_base
msgid "France"
msgstr ""
#. module: l10n_fr_association
#: model_terms:ir.ui.view,arch_db:l10n_fr_association.res_country_view_search
msgid "French"
msgstr "Français"
#. module: l10n_fr_association
#: model:ir.model.fields,field_description:l10n_fr_association.field_res_country__is_french
msgid "French country"
msgstr "Pays français"
#. module: l10n_fr_association
#: model:ir.model.fields,field_description:l10n_fr_association.field_res_partner__is_french
#: model:ir.model.fields,field_description:l10n_fr_association.field_res_users__is_french
@ -155,6 +185,11 @@ msgstr "Partenaire français"
msgid "General Assembly"
msgstr "Asemblée Ganérale"
#. module: l10n_fr_association
#: model_terms:ir.ui.view,arch_db:l10n_fr_association.view_res_partner_filter_inherit_base
msgid "Hexagon"
msgstr "Hexagone"
#. module: l10n_fr_association
#: model:ir.model.fields,field_description:l10n_fr_association.field_res_partner_relation_instance__id
msgid "ID"

1
l10n_fr_association/models/__init__.py

@ -1,4 +1,5 @@
# -*- coding: utf-8 -*-
from . import res_country
from . import res_partner_relation_instance
from . import res_partner_relation_type
from . import res_partner

10
l10n_fr_association/models/res_country.py

@ -0,0 +1,10 @@
# -*- coding: utf-8 -*-
from odoo import models, fields, api
class ResCountry(models.Model):
_inherit = "res.country"
is_french = fields.Boolean(
string="French country",
)

16
l10n_fr_association/models/res_partner.py

@ -7,7 +7,9 @@ class ResPartner(models.Model):
association = fields.Boolean(string="Is an association")
is_french = fields.Boolean(
string="French partner", compute="partner_is_french", store=True
string="French partner",
related="country_id.is_french",
store=True,
)
constituent_ga_date = fields.Date(
string="Consitutent GA",
@ -75,18 +77,6 @@ class ResPartner(models.Model):
asso_project_filename = fields.Char("Assocation project filename", tracking="83")
asso_project_update_date = fields.Date("Project update", tracking="83")
@api.depends("country_id")
def partner_is_french(self):
for partner in self:
partner.is_french = partner.country_id and partner.country_id.code in (
"FR",
"GP",
"MQ",
"GF",
"RE",
"YT",
)
@api.onchange("is_company", "country_id")
def onchange_asso_is_french_company(self):
if self.association and (not self.is_company or not self.is_french):

30
l10n_fr_association/views/res_country.xml

@ -0,0 +1,30 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<record id="view_country_form_inherit_base" model="ir.ui.view">
<field name="name">res.country.view.form.inherit</field>
<field name="model">res.country</field>
<field name="inherit_id" ref="base.view_country_form" />
<field name="priority">30</field>
<field name="arch" type="xml">
<field name="state_required" position="after">
<field name="is_french" groups="base.group_no_one" />
</field>
</field>
</record>
<record id="res_country_view_search" model="ir.ui.view">
<field name="name">res.country.view.search</field>
<field name="model">res.country</field>
<field name="arch" type="xml">
<search>
<filter name="french" string="French" domain="[('is_french', '=', True)]" />
<filter name="europe" string="Europe" domain="[('country_group_ids', 'in', %(base.europe)d)]" />
<group name="group_by" expand="0">
<filter name="by_group" string="Country Group" context="{'group_by': 'country_group_ids'}" />
</group>
</search>
</field>
</record>
</odoo>

5
l10n_fr_association/views/res_partner.xml

@ -63,6 +63,7 @@
<field name="name">res.partner.view.form.inherit</field>
<field name="model">res.partner</field>
<field name="inherit_id" ref="l10n_fr.res_partner_form_l10n_fr" />
<field name="priority">20</field>
<field name="arch" type="xml">
<field name="siret" position="attributes">
<attribute name="attrs">{'invisible': ['|',('is_company','=',False),('association','=',True)]}</attribute>
@ -77,9 +78,13 @@
<field name="name">res.partner.view.search.inherit</field>
<field name="model">res.partner</field>
<field name="inherit_id" ref="base.view_res_partner_filter" />
<field name="priority">20</field>
<field name="arch" type="xml">
<filter name="type_company" position="after">
<filter name="association" string="Associations" domain="[('association','=',True)]" />
<separator />
<filter name="france" string="France" domain="[('is_french','=',True)]" />
<filter name="hexagon" string="Hexagon" domain="[('country_id','=',%(base.fr)d)]" />
</filter>
</field>
</record>

2
l10n_fr_association/views/res_partner_relation_type.xml

@ -5,6 +5,7 @@
<field name="name">res.partner.relation.type.view.form.inherit</field>
<field name="model">res.partner.relation.type</field>
<field name="inherit_id" ref="partner_multi_relation.form_res_partner_relation_type" />
<field name="priority">20</field>
<field name="arch" type="xml">
<group name="properties" position="replace">
<group name='properties' string="Properties">
@ -26,6 +27,7 @@
<field name="name">res.partner.relation.type.view.tree.inherit</field>
<field name="model">res.partner.relation.type</field>
<field name="inherit_id" ref="partner_multi_relation.tree_res_partner_relation_type" />
<field name="priority">20</field>
<field name="arch" type="xml">
<field name="name" position="before">
<field name="insctance_id" widget="selection" />

Loading…
Cancel
Save