[MIG] partner_gogocarto_export_api : Migration to 16.0

This commit is contained in:
Boris Gallet
2024-03-06 15:36:52 +01:00
committed by Stéphan Sainléger
parent 1c6f4a3d4c
commit 70694c19de
16 changed files with 431 additions and 0 deletions

View File

@@ -0,0 +1,2 @@
*.*~
*pyc

View File

@@ -0,0 +1,66 @@
============================
partner_gogocarto_export_api
============================
Gogocarto Export module, to export the partner data needed for a Gogocarto map.
This module allow the users to decide:
* the partners to be exported
* the fields exported for each partner (*name*, *partner_longitude* and *partner_lattitude* automatically exported)
Installation
============
Use Odoo normal module installation procedure to install
``partner_gogocarto_export_api``, all dependencies will be installed by default.
Configuration
=============
To export partners data:
#. Set the fields you want to export in Settings / Gogocarto.
#. Check the field *"Export to Gogocarto"* in the partner form view.
And use the link *https://yourodoo.com/web/<company_id>/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 <https://github.com/elabore-coop/partner-tools/issues>`_. 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 SAINLEGER <https://github.com/stephansainleger>
* Chloé Migayrou <https://github.com/MigayrouChloe>
* Nicolas Jeudy <https://github.com/njeudy>
* Lokavaluto Teams <https://lokavaluto.fr>
Funders
-------
The development of this module has been financially supported by:
* Lokavaluto (https://lokavaluto.fr)
* Mycéliandre (https://myceliandre.fr)
* Elabore (https://elabore.coop)
Maintainer
----------
This module is maintained by Elabore and Lokavaluto.

View File

@@ -0,0 +1,2 @@
from . import controllers
from . import models

View File

@@ -0,0 +1,27 @@
{
'name': 'partner_gogocarto_export_api',
'summary': '''HTTP JSON api to send partner data for Gogocarto import''',
'license': 'AGPL-3',
'author': (
'Lokavaluto',
'Elabore'
),
'website': 'https://lokavaluto.fr',
'category': 'Localization',
'version': "16.0.1.0.0",
'depends': [
'base',
'contacts',
'base_geolocalize',
'partner_geolocalize_usability',
'jsonifier',
],
'data': [
'views/gogocarto_partner.xml',
'views/gogocarto_config_settings_view.xml',
'views/res_company_view.xml',
],
'demo': [],
'installable': True,
'auto_install': False,
}

View File

@@ -0,0 +1 @@
from . import main

View File

@@ -0,0 +1,29 @@
import json
import logging
from odoo import http
from odoo.http import Response, request
_logger = logging.getLogger(__name__)
class PartnerGogocartojs(http.Controller):
@http.route(
'/web/<company_id>/get_http_gogocarto_elements',
methods=['GET'],
type='http',
csrf=False,
auth="public",
website=True)
def get_gogocarto_elements_http(self, company_id):
data = self._jsonify_get_partner(company_id)
return Response(json.dumps(data))
def _jsonify_get_partner(self, company_id):
PartnerSudo = request.env['res.partner'].sudo()
parser = PartnerSudo._get_gogocarto_parser(company_id)
partners = PartnerSudo.with_context(force_company=company_id).search(
PartnerSudo._get_gogocarto_domain(company_id)
)
return partners.jsonify(parser)

View File

@@ -0,0 +1,73 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * partner_gogocarto_export_api
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 12.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2023-09-12 14:05+0000\n"
"PO-Revision-Date: 2023-09-12 14:05+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_gogocarto_export_api
#: model_terms:ir.ui.view,arch_db:partner_gogocarto_export_api.res_config_settings_view_form_gogocarto
msgid "Check the export on /web/{COMPANY_ID}/get_http_gogocarto_elements."
msgstr "Vérifiez l'export sur /web/{COMPANY_ID}/get_http_gogocarto_elements.\""
#. module: partner_gogocarto_export_api
#: model:ir.model,name:partner_gogocarto_export_api.model_res_company
msgid "Companies"
msgstr "Sociétés"
#. module: partner_gogocarto_export_api
#: model:ir.model,name:partner_gogocarto_export_api.model_res_config_settings
msgid "Config Settings"
msgstr "Paramètres de config"
#. module: partner_gogocarto_export_api
#: model:ir.model,name:partner_gogocarto_export_api.model_res_partner
msgid "Contact"
msgstr ""
#. module: partner_gogocarto_export_api
#: model:ir.model.fields,field_description:partner_gogocarto_export_api.field_res_company__export_gogocarto_fields
msgid "Export Gogocarto Fields"
msgstr "Champs exportés dans Gogocarto"
#. module: partner_gogocarto_export_api
#: model:ir.model.fields,field_description:partner_gogocarto_export_api.field_res_partner__in_gogocarto
#: model:ir.model.fields,field_description:partner_gogocarto_export_api.field_res_users__in_gogocarto
msgid "Export to Gogocarto"
msgstr "Exporter dans Gogocarto"
#. module: partner_gogocarto_export_api
#: model:ir.model.fields,field_description:partner_gogocarto_export_api.field_res_config_settings__export_gogocarto_fields
msgid "GogoCarto Exported fields"
msgstr "Champs exportés dans Gogocarto"
#. module: partner_gogocarto_export_api
#: model_terms:ir.ui.view,arch_db:partner_gogocarto_export_api.res_company_gogocarto_form_view
msgid "GogoCarto Setup"
msgstr "Gogocarto"
#. module: partner_gogocarto_export_api
#: model_terms:ir.ui.view,arch_db:partner_gogocarto_export_api.res_config_settings_view_form_gogocarto
msgid "Gogocarto"
msgstr ""
#. module: partner_gogocarto_export_api
#: model_terms:ir.ui.view,arch_db:partner_gogocarto_export_api.res_config_settings_view_form_gogocarto
msgid "Gogocarto export configuration"
msgstr "Configuration de l'export Gogocarto"
#. module: partner_gogocarto_export_api
#: model_terms:ir.ui.view,arch_db:partner_gogocarto_export_api.res_config_settings_view_form_gogocarto
msgid "Partner fields to export for Gogocarto map."
msgstr "Champs de contact à exporter vers Gogocarto."

View File

@@ -0,0 +1,73 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * partner_gogocarto_export_api
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 12.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2023-09-12 14:00+0000\n"
"PO-Revision-Date: 2023-09-12 14:00+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_gogocarto_export_api
#: model_terms:ir.ui.view,arch_db:partner_gogocarto_export_api.res_config_settings_view_form_gogocarto
msgid "Check the export on /web/{COMPANY_ID}/get_http_gogocarto_elements."
msgstr ""
#. module: partner_gogocarto_export_api
#: model:ir.model,name:partner_gogocarto_export_api.model_res_company
msgid "Companies"
msgstr ""
#. module: partner_gogocarto_export_api
#: model:ir.model,name:partner_gogocarto_export_api.model_res_config_settings
msgid "Config Settings"
msgstr ""
#. module: partner_gogocarto_export_api
#: model:ir.model,name:partner_gogocarto_export_api.model_res_partner
msgid "Contact"
msgstr ""
#. module: partner_gogocarto_export_api
#: model:ir.model.fields,field_description:partner_gogocarto_export_api.field_res_company__export_gogocarto_fields
msgid "Export Gogocarto Fields"
msgstr ""
#. module: partner_gogocarto_export_api
#: model:ir.model.fields,field_description:partner_gogocarto_export_api.field_res_partner__in_gogocarto
#: model:ir.model.fields,field_description:partner_gogocarto_export_api.field_res_users__in_gogocarto
msgid "Export to Gogocarto"
msgstr ""
#. module: partner_gogocarto_export_api
#: model:ir.model.fields,field_description:partner_gogocarto_export_api.field_res_config_settings__export_gogocarto_fields
msgid "GogoCarto Exported fields"
msgstr ""
#. module: partner_gogocarto_export_api
#: model_terms:ir.ui.view,arch_db:partner_gogocarto_export_api.res_company_gogocarto_form_view
msgid "GogoCarto Setup"
msgstr ""
#. module: partner_gogocarto_export_api
#: model_terms:ir.ui.view,arch_db:partner_gogocarto_export_api.res_config_settings_view_form_gogocarto
msgid "Gogocarto"
msgstr ""
#. module: partner_gogocarto_export_api
#: model_terms:ir.ui.view,arch_db:partner_gogocarto_export_api.res_config_settings_view_form_gogocarto
msgid "Gogocarto export configuration"
msgstr ""
#. module: partner_gogocarto_export_api
#: model_terms:ir.ui.view,arch_db:partner_gogocarto_export_api.res_config_settings_view_form_gogocarto
msgid "Partner fields to export for Gogocarto map."
msgstr ""

View File

@@ -0,0 +1,3 @@
from . import res_partner
from . import res_config_settings
from . import company

View File

@@ -0,0 +1,13 @@
from odoo import models, fields
class Company(models.Model):
_inherit = "res.company"
export_gogocarto_fields = fields.Many2many(
'ir.model.fields',
domain=[
('model_id', '=', 'res.partner'),
('name', 'not in', ['id', 'name', 'partner_longitude', 'partner_latitude'])
]
)

View File

@@ -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_fields = fields.Many2many(
related='company_id.export_gogocarto_fields',
relation='ir.model.fields',
string='GogoCarto Exported fields',
readonly=False,
domain=[
('model_id', '=', 'res.partner'),
('name', 'not in', ['name',
'partner_longitude',
'partner_latitude',
'id'])
]
)

View File

@@ -0,0 +1,50 @@
from odoo import models, fields
class ResPartner(models.Model):
""" Inherits partner, adds Gogocarto fields in the partner form, and functions"""
_inherit = 'res.partner'
in_gogocarto = fields.Boolean('Export to Gogocarto')
def _get_gogocarto_domain(self, company_id):
# To OVERRIDE in sub_modules to customize the partner selection
return [('in_gogocarto', '=', True)]
def _get_generic_parser(self, fields):
parser = []
for field in fields:
if field.ttype in [
"boolean",
"char",
"integer",
"monetary",
"text",
"selection",
"float",
"date_time",
"date"]:
parser.append(field.name)
elif field.ttype in ["many2one", "one2many", "many2many"]:
parser.append((field.name, ['id', 'name']))
elif field.ttype == "binary":
continue
elif field.ttype == "html":
continue # Not developped so far
else:
continue
return parser
def _get_gogocarto_parser(self, company_id):
fields = self._get_export_fields(company_id)
parser = self._get_generic_parser(fields)
return parser
def _get_export_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_fields
export_fields = default_fields | company_fields
return export_fields

Binary file not shown.

After

Width:  |  Height:  |  Size: 52 KiB

View File

@@ -0,0 +1,37 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<record id="res_config_settings_view_form_gogocarto" model="ir.ui.view">
<field name="name">res.config.settings.view.form.inherit.gogocarto</field>
<field name="model">res.config.settings</field>
<field name="priority" eval="99" />
<field name="inherit_id" ref="base.res_config_settings_view_form" />
<field name="arch" type="xml">
<xpath expr="//div[hasclass('settings')]" position="inside">
<div class="app_settings_block" data-string="Gogocarto" string="Gogocarto"
data-key="partner_gogocarto_export_api">
<h2>Gogocarto export configuration</h2>
<div class="text-muted mt16 o_settings_container">
Check the export on /web/{COMPANY_ID}/get_http_gogocarto_elements.
</div>
<div class="row mt16 o_settings_container" id="gogocarto_selection_settings">
<div class="col-12 col-lg-6 o_setting_box" id="gogocarto_fields">
<div class="o_setting_right_pane">
<div class="text-muted">
Partner fields to export for Gogocarto map.
</div>
<div class="content-group">
<div class="mt16">
<field name="export_gogocarto_fields"
widget="many2many_tags"
options="{'no_create': True, 'no_open': True}" />
</div>
</div>
</div>
</div>
</div>
</div>
</xpath>
</field>
</record>
</odoo>

View File

@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<odoo>
<record model="ir.ui.view" id="partner_gogocarto_form_view">
<field name="name">partner.gogocarto.form</field>
<field name="model">res.partner</field>
<field name="inherit_id" ref="partner_geolocalize_usability.partner_geolocalize_form_view" />
<field name='priority'>99</field>
<field name="arch" type="xml">
<xpath expr="//page[@name='geolocalize']/group" position="inside">
<field name="in_gogocarto" />
</xpath>
</field>
</record>
</odoo>

View File

@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<odoo>
<record model="ir.ui.view" id="res_company_gogocarto_form_view">
<field name="name">res_company.gogocarto.form</field>
<field name="model">res.company</field>
<field name="inherit_id" ref="base.view_company_form"/>
<field name='priority'>99</field>
<field name="arch" type="xml">
<xpath expr="//notebook" posiion="inside">
<page string="GogoCarto Setup" name="gogocarto">
<group>
<field name="export_gogocarto_fields"/>
</group>
</page>
</xpath>
</field>
</record>
</odoo>