[IMP] partner_profiles: add sync function for admin and public data

This commit is contained in:
Stéphan Sainléger
2023-09-12 17:00:00 +02:00
parent 1a1ff2f35c
commit 259ff54eb7
5 changed files with 57 additions and 8 deletions

View File

@@ -3,7 +3,7 @@
{ {
"name": "partner_profiles", "name": "partner_profiles",
"version": "12.0.2.4.1", "version": "12.0.2.5.0",
"author": "Elabore", "author": "Elabore",
"website": "https://elabore.coop", "website": "https://elabore.coop",
"maintainer": "Stéphan Sainléger", "maintainer": "Stéphan Sainléger",

View File

@@ -6,8 +6,8 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: Odoo Server 12.0\n" "Project-Id-Version: Odoo Server 12.0\n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2023-06-13 15:25+0000\n" "POT-Creation-Date: 2023-09-12 15:03+0000\n"
"PO-Revision-Date: 2023-06-13 15:25+0000\n" "PO-Revision-Date: 2023-09-12 15:03+0000\n"
"Last-Translator: <>\n" "Last-Translator: <>\n"
"Language-Team: \n" "Language-Team: \n"
"MIME-Version: 1.0\n" "MIME-Version: 1.0\n"
@@ -73,7 +73,7 @@ msgstr "<span>Vous trouverez ici <strong>tou(te)s</strong> les adresses/contacts
msgid "<span>You are about to create a <strong>Position Profile</strong> which\n" msgid "<span>You are about to create a <strong>Position Profile</strong> which\n"
" represents the role or the job of a person in a structure.</span>" " represents the role or the job of a person in a structure.</span>"
msgstr "<span>Vous allez créer une <strong>fiche Fonction</strong> qui\n" msgstr "<span>Vous allez créer une <strong>fiche Fonction</strong> qui\n"
" représente le rôle que tient une personne au sein d'une structure.</span>"" " représente le rôle que tient une personne au sein d'une structure.</span>\""
#. module: partner_profiles #. module: partner_profiles
#: model_terms:ir.ui.view,arch_db:partner_profiles.partner_profiles_form_view #: model_terms:ir.ui.view,arch_db:partner_profiles.partner_profiles_form_view
@@ -337,12 +337,12 @@ msgstr "État"
#. module: partner_profiles #. module: partner_profiles
#: model_terms:ir.ui.view,arch_db:partner_profiles.partner_profiles_form_view #: model_terms:ir.ui.view,arch_db:partner_profiles.partner_profiles_form_view
msgid "Street 2..." msgid "Street 2..."
msgstr "Rue 2 ..." msgstr "Rue 2..."
#. module: partner_profiles #. module: partner_profiles
#: model_terms:ir.ui.view,arch_db:partner_profiles.partner_profiles_form_view #: model_terms:ir.ui.view,arch_db:partner_profiles.partner_profiles_form_view
msgid "Street..." msgid "Street..."
msgstr "Rue.." msgstr "Rue..."
#. module: partner_profiles #. module: partner_profiles
#: model:ir.model.fields,field_description:partner_profiles.field_create_position_profile__structure_id #: model:ir.model.fields,field_description:partner_profiles.field_create_position_profile__structure_id
@@ -355,6 +355,16 @@ msgstr ""
msgid "Structure's positions" msgid "Structure's positions"
msgstr "Fonctions occupées dans la structures" msgstr "Fonctions occupées dans la structures"
#. module: partner_profiles
#: model_terms:ir.ui.view,arch_db:partner_profiles.partner_profiles_form_view
msgid "Sync data"
msgstr "Synchroniser"
#. module: partner_profiles
#: model:ir.actions.server,name:partner_profiles.sync_public_data_action_server
msgid "Synchronize main and public data"
msgstr "Synchroniser les données publiques"
#. module: partner_profiles #. module: partner_profiles
#: model:ir.model.fields,field_description:partner_profiles.field_res_partner__to_migrate #: model:ir.model.fields,field_description:partner_profiles.field_res_partner__to_migrate
#: model:ir.model.fields,field_description:partner_profiles.field_res_users__to_migrate #: model:ir.model.fields,field_description:partner_profiles.field_res_users__to_migrate

View File

@@ -6,8 +6,8 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: Odoo Server 12.0\n" "Project-Id-Version: Odoo Server 12.0\n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2023-06-13 15:24+0000\n" "POT-Creation-Date: 2023-09-12 15:02+0000\n"
"PO-Revision-Date: 2023-06-13 15:24+0000\n" "PO-Revision-Date: 2023-09-12 15:02+0000\n"
"Last-Translator: <>\n" "Last-Translator: <>\n"
"Language-Team: \n" "Language-Team: \n"
"MIME-Version: 1.0\n" "MIME-Version: 1.0\n"
@@ -340,6 +340,16 @@ msgstr ""
msgid "Structure's positions" msgid "Structure's positions"
msgstr "" msgstr ""
#. module: partner_profiles
#: model_terms:ir.ui.view,arch_db:partner_profiles.partner_profiles_form_view
msgid "Sync data"
msgstr ""
#. module: partner_profiles
#: model:ir.actions.server,name:partner_profiles.sync_public_data_action_server
msgid "Synchronize main and public data"
msgstr ""
#. module: partner_profiles #. module: partner_profiles
#: model:ir.model.fields,field_description:partner_profiles.field_res_partner__to_migrate #: model:ir.model.fields,field_description:partner_profiles.field_res_partner__to_migrate
#: model:ir.model.fields,field_description:partner_profiles.field_res_users__to_migrate #: model:ir.model.fields,field_description:partner_profiles.field_res_users__to_migrate

View File

@@ -255,6 +255,22 @@ class res_partner(models.Model):
args.append(("is_public_profile", "=", False)) args.append(("is_public_profile", "=", False))
return super(res_partner, self).name_search(name, args, operator, limit) return super(res_partner, self).name_search(name, args, operator, limit)
@api.multi
def sync_admin_and_public_data(self):
for partner in self:
if partner.is_main_profile and partner.public_profile_id:
main_partner = partner
public_partner = partner.public_profile_id
elif partner.is_public_profile and partner.contact_id:
main_partner = partner.contact_id
public_partner = partner
public_fields = partner._get_public_profile_fields()
values = {}
for field_name in public_fields:
values[field_name] = main_partner._get_field_value(field_name)
public_partner.write(values)
################################################################################## ##################################################################################
## Planned actions ## Planned actions
################################################################################## ##################################################################################

View File

@@ -42,6 +42,10 @@
<button type="object" name="create_public_profile" <button type="object" name="create_public_profile"
string="Create Public Profile" string="Create Public Profile"
attrs="{'invisible': [('public_profile_id','!=',False)]}" /> attrs="{'invisible': [('public_profile_id','!=',False)]}" />
<button string="Sync data"
name="sync_admin_and_public_data" type="object"
icon="fa-refresh"
attrs="{'invisible': [('public_profile_id','=',False)]}" />
</div> </div>
</group> </group>
</group> </group>
@@ -196,6 +200,7 @@
options='{"no_open": True, "no_create": True}' options='{"no_open": True, "no_create": True}'
attrs="{'readonly': [('type', '=', 'contact'),('parent_id', '!=', False)]}" /> attrs="{'readonly': [('type', '=', 'contact'),('parent_id', '!=', False)]}" />
</div> </div>
</group> </group>
<group> <group>
<field name="phone" widget="phone" /> <field name="phone" widget="phone" />
@@ -258,5 +263,13 @@
</xpath> </xpath>
</field> </field>
</record> </record>
<record id="sync_public_data_action_server" model="ir.actions.server">
<field name="name">Synchronize main and public data</field>
<field name="model_id" ref="model_res_partner" />
<field name="groups_id" eval="[(4,ref('base.group_no_one'))]" />
<field name="state">code</field>
<field name="code">records.sync_admin_and_public_data() </field>
</record>
</data> </data>
</odoo> </odoo>