[NEW] partner_gogocarto_export_api: create add-on
Transfers add-on partner_gogocarto_export_api from OCA partner-contact repo
This commit is contained in:
committed by
Stéphan Sainléger
parent
9325c02b53
commit
de273ec571
1
partner_gogocarto_export_api/README.rst
Normal file
1
partner_gogocarto_export_api/README.rst
Normal file
@@ -0,0 +1 @@
|
|||||||
|
This file is going to be generated by oca-gen-addon-readme.
|
2
partner_gogocarto_export_api/__init__.py
Normal file
2
partner_gogocarto_export_api/__init__.py
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
from . import controllers
|
||||||
|
from . import models
|
26
partner_gogocarto_export_api/__manifest__.py
Normal file
26
partner_gogocarto_export_api/__manifest__.py
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
{
|
||||||
|
'name': 'partner_gogocarto_export_api',
|
||||||
|
'summary': '''HTTP JSON api to send partner data for Gogocarto import''',
|
||||||
|
'license': 'AGPL-3',
|
||||||
|
'author': (
|
||||||
|
'Lokavaluto,'
|
||||||
|
'Odoo Community Association (OCA)'
|
||||||
|
),
|
||||||
|
'website': 'https://lokavaluto.fr',
|
||||||
|
'category': 'Localization',
|
||||||
|
'version': '12.0.1.0.0',
|
||||||
|
'depends': [
|
||||||
|
'base',
|
||||||
|
'contacts',
|
||||||
|
'base_geolocalize',
|
||||||
|
'base_jsonify',
|
||||||
|
],
|
||||||
|
'data': [
|
||||||
|
'views/gogocarto_partner.xml',
|
||||||
|
'views/gogocarto_config_settings_view.xml',
|
||||||
|
'views/res_company_view.xml',
|
||||||
|
],
|
||||||
|
'demo': [],
|
||||||
|
'installable': True,
|
||||||
|
'auto_install': False,
|
||||||
|
}
|
1
partner_gogocarto_export_api/controllers/__init__.py
Normal file
1
partner_gogocarto_export_api/controllers/__init__.py
Normal file
@@ -0,0 +1 @@
|
|||||||
|
from . import main
|
29
partner_gogocarto_export_api/controllers/main.py
Normal file
29
partner_gogocarto_export_api/controllers/main.py
Normal 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)
|
3
partner_gogocarto_export_api/models/__init__.py
Normal file
3
partner_gogocarto_export_api/models/__init__.py
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
from . import res_partner
|
||||||
|
from . import res_config_settings
|
||||||
|
from . import company
|
13
partner_gogocarto_export_api/models/company.py
Normal file
13
partner_gogocarto_export_api/models/company.py
Normal 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'])
|
||||||
|
]
|
||||||
|
)
|
23
partner_gogocarto_export_api/models/res_config_settings.py
Normal file
23
partner_gogocarto_export_api/models/res_config_settings.py
Normal 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'])
|
||||||
|
]
|
||||||
|
)
|
47
partner_gogocarto_export_api/models/res_partner.py
Normal file
47
partner_gogocarto_export_api/models/res_partner.py
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
from odoo import models, fields
|
||||||
|
import logging
|
||||||
|
_logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
|
class ResPartner(models.Model):
|
||||||
|
""" Inherits partner, adds Gogocarto fields in the partner form, and functions"""
|
||||||
|
_inherit = 'res.partner'
|
||||||
|
|
||||||
|
in_gogocarto = fields.Boolean('In gogocarto')
|
||||||
|
|
||||||
|
def _get_gogocarto_domain(self, company_id):
|
||||||
|
# To OVERRIDE in sub_modules to customize the partner selection
|
||||||
|
return [('in_gogocarto', '=', True)]
|
||||||
|
|
||||||
|
def _get_gogocarto_parser(self, company_id):
|
||||||
|
parser = []
|
||||||
|
for field in self._get_export_fields(company_id):
|
||||||
|
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_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
|
8
partner_gogocarto_export_api/readme/CONFIGURE.rst
Normal file
8
partner_gogocarto_export_api/readme/CONFIGURE.rst
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
Just install partner_gogocarto_export_api, all dependencies will be installed by default.
|
||||||
|
|
||||||
|
To export partners data:
|
||||||
|
|
||||||
|
#. Set the fields you want to export in Settings / Gogocarto.
|
||||||
|
#. Check the field *"In 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*)
|
13
partner_gogocarto_export_api/readme/CONTRIBUTORS.rst
Normal file
13
partner_gogocarto_export_api/readme/CONTRIBUTORS.rst
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
* 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)
|
1
partner_gogocarto_export_api/readme/CREDITS.rst
Normal file
1
partner_gogocarto_export_api/readme/CREDITS.rst
Normal file
@@ -0,0 +1 @@
|
|||||||
|
* Lokavaluto: `Icon <https://lokavaluto.fr/web/image/res.company/1/logo?unique=f3db262>`
|
6
partner_gogocarto_export_api/readme/DESCRIPTION.rst
Normal file
6
partner_gogocarto_export_api/readme/DESCRIPTION.rst
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
Gogocarto Export module, to export the partner data needed for a Gogocarto map.
|
||||||
|
|
||||||
|
This module allow the users to decide:
|
||||||
|
|
||||||
|
* the partner to be exported
|
||||||
|
* the fields exported for each partner (*name*, *partner_longitude* and *partner_lattitude* automatically exported)
|
BIN
partner_gogocarto_export_api/static/description/icon.png
Normal file
BIN
partner_gogocarto_export_api/static/description/icon.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 52 KiB |
@@ -0,0 +1,30 @@
|
|||||||
|
<?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="gogocarto">
|
||||||
|
<h2>Gogocarto export configuration</h2>
|
||||||
|
<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. Check the export on /web/get_http_gogocarto_elements.
|
||||||
|
</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>
|
14
partner_gogocarto_export_api/views/gogocarto_partner.xml
Normal file
14
partner_gogocarto_export_api/views/gogocarto_partner.xml
Normal 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="base.view_partner_form"/>
|
||||||
|
<field name='priority'>99</field>
|
||||||
|
<field name="arch" type="xml">
|
||||||
|
<xpath expr="//field[@name='function']" position="after">
|
||||||
|
<field name="in_gogocarto"/>
|
||||||
|
</xpath>
|
||||||
|
</field>
|
||||||
|
</record>
|
||||||
|
</odoo>
|
18
partner_gogocarto_export_api/views/res_company_view.xml
Normal file
18
partner_gogocarto_export_api/views/res_company_view.xml
Normal 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>
|
Reference in New Issue
Block a user