From 142a0342c97e68072c93e55c128b2fcc245f4bfa Mon Sep 17 00:00:00 2001 From: Boris Gallet Date: Wed, 6 Mar 2024 15:43:34 +0100 Subject: [PATCH] [MIG] partner_profiles_gogocarto_export : Migration to 16.0 --- partner_profiles_gogocarto_export/.gitignore | 2 + partner_profiles_gogocarto_export/README.rst | 56 +++++++++++++++++++ partner_profiles_gogocarto_export/__init__.py | 2 + .../__manifest__.py | 40 +++++++++++++ partner_profiles_gogocarto_export/i18n/README | 1 + partner_profiles_gogocarto_export/i18n/fr.po | 46 +++++++++++++++ .../partner_profiles_gogocarto_export.pot | 47 ++++++++++++++++ .../models/__init__.py | 3 + .../models/company.py | 14 +++++ .../models/res_config_settings.py | 23 ++++++++ .../models/res_partner.py | 29 ++++++++++ .../views/config_settings_view.xml | 26 +++++++++ .../views/res_company_view.xml | 16 ++++++ 13 files changed, 305 insertions(+) create mode 100644 partner_profiles_gogocarto_export/.gitignore create mode 100644 partner_profiles_gogocarto_export/README.rst create mode 100644 partner_profiles_gogocarto_export/__init__.py create mode 100644 partner_profiles_gogocarto_export/__manifest__.py create mode 100644 partner_profiles_gogocarto_export/i18n/README create mode 100644 partner_profiles_gogocarto_export/i18n/fr.po create mode 100644 partner_profiles_gogocarto_export/i18n/partner_profiles_gogocarto_export.pot create mode 100644 partner_profiles_gogocarto_export/models/__init__.py create mode 100644 partner_profiles_gogocarto_export/models/company.py create mode 100644 partner_profiles_gogocarto_export/models/res_config_settings.py create mode 100644 partner_profiles_gogocarto_export/models/res_partner.py create mode 100644 partner_profiles_gogocarto_export/views/config_settings_view.xml create mode 100644 partner_profiles_gogocarto_export/views/res_company_view.xml diff --git a/partner_profiles_gogocarto_export/.gitignore b/partner_profiles_gogocarto_export/.gitignore new file mode 100644 index 0000000..6da5887 --- /dev/null +++ b/partner_profiles_gogocarto_export/.gitignore @@ -0,0 +1,2 @@ +*.*~ +*pyc diff --git a/partner_profiles_gogocarto_export/README.rst b/partner_profiles_gogocarto_export/README.rst new file mode 100644 index 0000000..11fd77c --- /dev/null +++ b/partner_profiles_gogocarto_export/README.rst @@ -0,0 +1,56 @@ +================================ +partner_profiles_gogocarto_export +================================ + +Adapt data export for gogocarto to partner profiles logic + +Installation +============ + +Use Odoo normal module installation procedure to install +``partner_profiles_gogocarto_export``. + +Configuration +============= + +To export public partners data: + +#. Set the fields you want to export in Settings / Gogocarto, in the dedicated parameter for public profiles. +#. Check the field *"Export to Gogocarto"* in the partner form view of the main profile. + +And use the link *https://yourodoo.com/web//get_http_gogocarto_elements* in Gogocarto server import configuration (*https://video.colibris-outilslibres.org/videos/watch/c74fc469-c822-4ab8-82a7-a2555e49e576*) + + +Known issues / Roadmap +====================== + +None yet. + +Bug Tracker +=========== + +Bugs are tracked on `our issues website `_. In case of +trouble, please check there if your issue has already been +reported. If you spotted it first, help us smashing it by providing a +detailed and welcomed feedback. + +Credits +======= + +Contributors +------------ + +* Stéphan Sainléger + +Funders +------- + +The development of this module has been financially supported by: +* Elabore (https://elabore.coop) +* Lokavaluto (https://lokavaluto.fr) + + +Maintainer +---------- + +This module is maintained by Elabore and Lokavaluto. \ No newline at end of file diff --git a/partner_profiles_gogocarto_export/__init__.py b/partner_profiles_gogocarto_export/__init__.py new file mode 100644 index 0000000..a9e3372 --- /dev/null +++ b/partner_profiles_gogocarto_export/__init__.py @@ -0,0 +1,2 @@ + +from . import models diff --git a/partner_profiles_gogocarto_export/__manifest__.py b/partner_profiles_gogocarto_export/__manifest__.py new file mode 100644 index 0000000..50d7473 --- /dev/null +++ b/partner_profiles_gogocarto_export/__manifest__.py @@ -0,0 +1,40 @@ +# Copyright 2023 Stéphan Sainléger (Elabore) +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +{ + "name": "partner_profiles_gogocarto_export", + "version": "16.0.1.0.0", + "author": "Elabore", + "website": "https://elabore.coop", + "maintainer": "Stéphan Sainléger", + "license": "AGPL-3", + "category": "Tools", + "summary": "Adapt data export for gogocarto to partner profiles logic", + # any module necessary for this one to work correctly + "depends": [ + "base", + "partner_gogocarto_export_api", + "partner_profiles", + "partner_profiles_geolocalize_usability", + ], + "qweb": [ + # "static/src/xml/*.xml", + ], + "external_dependencies": { + "python": [], + }, + # always loaded + "data": [ + "views/config_settings_view.xml", + "views/res_company_view.xml", + ], + # only loaded in demonstration mode + "demo": [], + "js": [], + "css": [], + "installable": True, + # Install this module automatically if all dependency have been previously + # and independently installed. Used for synergetic or glue modules. + "auto_install": False, + "application": False, +} \ No newline at end of file diff --git a/partner_profiles_gogocarto_export/i18n/README b/partner_profiles_gogocarto_export/i18n/README new file mode 100644 index 0000000..62197a1 --- /dev/null +++ b/partner_profiles_gogocarto_export/i18n/README @@ -0,0 +1 @@ +This directory should contain the *.po for Odoo translation. diff --git a/partner_profiles_gogocarto_export/i18n/fr.po b/partner_profiles_gogocarto_export/i18n/fr.po new file mode 100644 index 0000000..ab64f93 --- /dev/null +++ b/partner_profiles_gogocarto_export/i18n/fr.po @@ -0,0 +1,46 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * partner_profiles_gogocarto_export +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 12.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2023-09-12 14:02+0000\n" +"PO-Revision-Date: 2023-09-12 14:02+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: partner_profiles_gogocarto_export +#: model:ir.model,name:partner_profiles_gogocarto_export.model_res_company +msgid "Companies" +msgstr "Sociétés" + +#. module: partner_profiles_gogocarto_export +#: model:ir.model,name:partner_profiles_gogocarto_export.model_res_config_settings +msgid "Config Settings" +msgstr "Paramètres de config" + +#. module: partner_profiles_gogocarto_export +#: model:ir.model,name:partner_profiles_gogocarto_export.model_res_partner +msgid "Contact" +msgstr "Contact" + +#. module: partner_profiles_gogocarto_export +#: model:ir.model.fields,field_description:partner_profiles_gogocarto_export.field_res_company__export_gogocarto_public_fields +msgid "Export Gogocarto Public Fields" +msgstr "Export Gogocarto des champs publics" + +#. module: partner_profiles_gogocarto_export +#: model:ir.model.fields,field_description:partner_profiles_gogocarto_export.field_res_config_settings__export_gogocarto_public_fields +msgid "GogoCarto Exported Public fields" +msgstr "Champs publics exportés dans Gogocarto" + +#. module: partner_profiles_gogocarto_export +#: model_terms:ir.ui.view,arch_db:partner_profiles_gogocarto_export.res_config_settings_view_form_gogocarto_public +msgid "Partner public fields to export for Gogocarto map." +msgstr "Champs publics à exporter dans Gogocarto" diff --git a/partner_profiles_gogocarto_export/i18n/partner_profiles_gogocarto_export.pot b/partner_profiles_gogocarto_export/i18n/partner_profiles_gogocarto_export.pot new file mode 100644 index 0000000..8c05dbb --- /dev/null +++ b/partner_profiles_gogocarto_export/i18n/partner_profiles_gogocarto_export.pot @@ -0,0 +1,47 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * partner_profiles_gogocarto_export +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 12.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2023-09-12 14:08+0000\n" +"PO-Revision-Date: 2023-09-12 14:08+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: partner_profiles_gogocarto_export +#: model:ir.model,name:partner_profiles_gogocarto_export.model_res_company +msgid "Companies" +msgstr "" + +#. module: partner_profiles_gogocarto_export +#: model:ir.model,name:partner_profiles_gogocarto_export.model_res_config_settings +msgid "Config Settings" +msgstr "" + +#. module: partner_profiles_gogocarto_export +#: model:ir.model,name:partner_profiles_gogocarto_export.model_res_partner +msgid "Contact" +msgstr "" + +#. module: partner_profiles_gogocarto_export +#: model:ir.model.fields,field_description:partner_profiles_gogocarto_export.field_res_company__export_gogocarto_public_fields +msgid "Export Gogocarto Public Fields" +msgstr "" + +#. module: partner_profiles_gogocarto_export +#: model:ir.model.fields,field_description:partner_profiles_gogocarto_export.field_res_config_settings__export_gogocarto_public_fields +msgid "GogoCarto Exported Public fields" +msgstr "" + +#. module: partner_profiles_gogocarto_export +#: model_terms:ir.ui.view,arch_db:partner_profiles_gogocarto_export.res_config_settings_view_form_gogocarto_public +msgid "Partner public fields to export for Gogocarto map." +msgstr "" + diff --git a/partner_profiles_gogocarto_export/models/__init__.py b/partner_profiles_gogocarto_export/models/__init__.py new file mode 100644 index 0000000..d72b918 --- /dev/null +++ b/partner_profiles_gogocarto_export/models/__init__.py @@ -0,0 +1,3 @@ +from . import res_config_settings +from . import company +from . import res_partner \ No newline at end of file diff --git a/partner_profiles_gogocarto_export/models/company.py b/partner_profiles_gogocarto_export/models/company.py new file mode 100644 index 0000000..10a3398 --- /dev/null +++ b/partner_profiles_gogocarto_export/models/company.py @@ -0,0 +1,14 @@ +from odoo import models, fields + + +class Company(models.Model): + _inherit = "res.company" + + export_gogocarto_public_fields = fields.Many2many( + 'ir.model.fields', + relation='ir_model_fields_gogocarto_public', + domain=[ + ('model_id', '=', 'res.partner'), + ('name', 'not in', ['id', 'name', 'partner_longitude', 'partner_latitude']) + ] + ) diff --git a/partner_profiles_gogocarto_export/models/res_config_settings.py b/partner_profiles_gogocarto_export/models/res_config_settings.py new file mode 100644 index 0000000..62d287c --- /dev/null +++ b/partner_profiles_gogocarto_export/models/res_config_settings.py @@ -0,0 +1,23 @@ +import logging +from odoo import fields, models + + +_logger = logging.getLogger(__name__) + + +class ResConfigSettings(models.TransientModel): + _inherit = 'res.config.settings' + + export_gogocarto_public_fields = fields.Many2many( + related='company_id.export_gogocarto_public_fields', + relation='ir.model.fields', + string='GogoCarto Exported Public fields', + readonly=False, + domain=[ + ('model_id', '=', 'res.partner'), + ('name', 'not in', ['name', + 'partner_longitude', + 'partner_latitude', + 'id']) + ] + ) diff --git a/partner_profiles_gogocarto_export/models/res_partner.py b/partner_profiles_gogocarto_export/models/res_partner.py new file mode 100644 index 0000000..937fb42 --- /dev/null +++ b/partner_profiles_gogocarto_export/models/res_partner.py @@ -0,0 +1,29 @@ +from odoo import models +import logging + + +class ResPartner(models.Model): + """ Inherits partner, adds Gogocarto public fields in the partner form, and functions""" + _inherit = 'res.partner' + + def _get_gogocarto_domain(self, company_id): + # To OVERRIDE in sub_modules to customize the partner selection + res = super(ResPartner, self)._get_gogocarto_domain(company_id) + res.extend([('is_main_profile', '=', True)]) + return res + + def _get_gogocarto_parser(self, company_id): + parser = super(ResPartner, self)._get_gogocarto_parser(company_id) + public_fields = self._get_export_public_fields(company_id) + public_parser = self._get_generic_parser(public_fields) + parser.append(("public_profile_id", public_parser)) + return parser + + def _get_export_public_fields(self, company_id): + CompanySudo = self.env['res.company'].sudo().search([('id', '=', company_id)]) + default_fields = self.env['ir.model.fields'].sudo().search([ + ('model_id', '=', 'res.partner'), + ('name', 'in', ['id', 'name', 'partner_longitude', 'partner_latitude'])]) + company_fields = CompanySudo.export_gogocarto_public_fields + export_fields = default_fields | company_fields + return export_fields diff --git a/partner_profiles_gogocarto_export/views/config_settings_view.xml b/partner_profiles_gogocarto_export/views/config_settings_view.xml new file mode 100644 index 0000000..ef9bc3f --- /dev/null +++ b/partner_profiles_gogocarto_export/views/config_settings_view.xml @@ -0,0 +1,26 @@ + + + + res.config.settings.view.form.inherit.gogocarto.public + res.config.settings + + + +
+
+
+ Partner public fields to export for Gogocarto map. +
+
+
+ +
+
+
+
+
+
+
+
\ No newline at end of file diff --git a/partner_profiles_gogocarto_export/views/res_company_view.xml b/partner_profiles_gogocarto_export/views/res_company_view.xml new file mode 100644 index 0000000..c9ed8b5 --- /dev/null +++ b/partner_profiles_gogocarto_export/views/res_company_view.xml @@ -0,0 +1,16 @@ + + + + res_company.gogocarto.public.form + res.company + + 99 + + + + + + + + + \ No newline at end of file