add website_partner_directory
This commit is contained in:
commit
9cabf044c8
12 changed files with 275 additions and 0 deletions
56
.gitignore
vendored
Normal file
56
.gitignore
vendored
Normal file
|
|
@ -0,0 +1,56 @@
|
||||||
|
# Archivos y carpetas generados por Odoo
|
||||||
|
*.log
|
||||||
|
*.pyc
|
||||||
|
*.pyo
|
||||||
|
__pycache__/
|
||||||
|
*.db
|
||||||
|
|
||||||
|
# Archivos de configuración de Odoo
|
||||||
|
*.sqlite
|
||||||
|
*.log
|
||||||
|
*.conf
|
||||||
|
|
||||||
|
# Archivos de cache de Odoo
|
||||||
|
*.pid
|
||||||
|
*.sock
|
||||||
|
*.swp
|
||||||
|
|
||||||
|
# Archivos de dependencias
|
||||||
|
*.egg
|
||||||
|
*.egg-info/
|
||||||
|
dist/
|
||||||
|
build/
|
||||||
|
|
||||||
|
# Entornos virtuales de Python
|
||||||
|
venv/
|
||||||
|
env/
|
||||||
|
|
||||||
|
# Archivos de la base de datos
|
||||||
|
*.db
|
||||||
|
*.dump
|
||||||
|
|
||||||
|
# Archivos de cobertura de prueba
|
||||||
|
.coverage
|
||||||
|
|
||||||
|
# Archivos de editor (emacs, vim, etc.)
|
||||||
|
*~
|
||||||
|
*.swp
|
||||||
|
.vscode/
|
||||||
|
.idea/
|
||||||
|
.DS_Store
|
||||||
|
|
||||||
|
# Archivos de paquetes de dependencias
|
||||||
|
node_modules/
|
||||||
|
*.bak
|
||||||
|
|
||||||
|
# Archivos de logs
|
||||||
|
*.log
|
||||||
|
*.out
|
||||||
|
|
||||||
|
# Archivos de configuraciones locales de Odoo
|
||||||
|
*.ini
|
||||||
|
|
||||||
|
# Archivos temporales de Odoo (y otros archivos temporales)
|
||||||
|
*.tmp
|
||||||
|
*.bak
|
||||||
|
*.swp
|
||||||
2
website_partner_directory/__init__.py
Normal file
2
website_partner_directory/__init__.py
Normal file
|
|
@ -0,0 +1,2 @@
|
||||||
|
from . import models
|
||||||
|
from . import controllers
|
||||||
18
website_partner_directory/__manifest__.py
Normal file
18
website_partner_directory/__manifest__.py
Normal file
|
|
@ -0,0 +1,18 @@
|
||||||
|
{
|
||||||
|
"name": "Partner Directory with Map",
|
||||||
|
"version": "17.0.1.0.0",
|
||||||
|
"summary": "Directorio de empresas en website con mapa Leaflet",
|
||||||
|
"category": "Website",
|
||||||
|
"author": "Luis",
|
||||||
|
"depends": ["website_partner", "base_geolocalize"],
|
||||||
|
"data": ["views/res_partner_views.xml", "views/directory_template.xml"],
|
||||||
|
"assets": {
|
||||||
|
"web.assets_frontend": [
|
||||||
|
"https://unpkg.com/leaflet/dist/leaflet.css",
|
||||||
|
"https://unpkg.com/leaflet/dist/leaflet.js",
|
||||||
|
# "website_partner_directory/static/src/js/map.js",
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"installable": True,
|
||||||
|
"license": "LGPL-3",
|
||||||
|
}
|
||||||
1
website_partner_directory/controllers/__init__.py
Normal file
1
website_partner_directory/controllers/__init__.py
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
from . import directory
|
||||||
26
website_partner_directory/controllers/directory.py
Normal file
26
website_partner_directory/controllers/directory.py
Normal file
|
|
@ -0,0 +1,26 @@
|
||||||
|
from odoo import http
|
||||||
|
from odoo.http import request
|
||||||
|
|
||||||
|
|
||||||
|
class DirectoryController(http.Controller):
|
||||||
|
|
||||||
|
@http.route(["/observatorio"], type="http", auth="public", website=True)
|
||||||
|
def directory(self, **kwargs):
|
||||||
|
partners = (
|
||||||
|
request.env["res.partner"]
|
||||||
|
.sudo()
|
||||||
|
.search(
|
||||||
|
[
|
||||||
|
("is_company", "=", True),
|
||||||
|
("show_in_directory", "=", True),
|
||||||
|
("partner_latitude", "!=", False),
|
||||||
|
("partner_longitude", "!=", False),
|
||||||
|
]
|
||||||
|
)
|
||||||
|
)
|
||||||
|
return request.render(
|
||||||
|
"website_partner_directory.directory_page",
|
||||||
|
{
|
||||||
|
"partners": partners,
|
||||||
|
},
|
||||||
|
)
|
||||||
BIN
website_partner_directory/i18n/es.mo
Normal file
BIN
website_partner_directory/i18n/es.mo
Normal file
Binary file not shown.
55
website_partner_directory/i18n/es.po
Normal file
55
website_partner_directory/i18n/es.po
Normal file
|
|
@ -0,0 +1,55 @@
|
||||||
|
# Translation of Odoo Server.
|
||||||
|
# This file contains the translation of the following modules:
|
||||||
|
# * website_partner_directory
|
||||||
|
#
|
||||||
|
msgid ""
|
||||||
|
msgstr ""
|
||||||
|
"Project-Id-Version: Odoo Server 17.0\n"
|
||||||
|
"Report-Msgid-Bugs-To: \n"
|
||||||
|
"POT-Creation-Date: 2025-08-14 15:56+0000\n"
|
||||||
|
"PO-Revision-Date: 2025-08-14 17:57+0200\n"
|
||||||
|
"Last-Translator: \n"
|
||||||
|
"Language-Team: \n"
|
||||||
|
"Language: es\n"
|
||||||
|
"MIME-Version: 1.0\n"
|
||||||
|
"Content-Type: text/plain; charset=UTF-8\n"
|
||||||
|
"Content-Transfer-Encoding: 8bit\n"
|
||||||
|
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
|
||||||
|
"X-Generator: Poedit 3.6\n"
|
||||||
|
|
||||||
|
#. module: website_partner_directory
|
||||||
|
#: model_terms:ir.ui.view,arch_db:website_partner_directory.directory_page
|
||||||
|
msgid "Company List"
|
||||||
|
msgstr "Listado de Empresas"
|
||||||
|
|
||||||
|
#. module: website_partner_directory
|
||||||
|
#: model_terms:ir.ui.view,arch_db:website_partner_directory.directory_page
|
||||||
|
msgid "Company Observatory"
|
||||||
|
msgstr "Observatorio de Empresas"
|
||||||
|
|
||||||
|
#. module: website_partner_directory
|
||||||
|
#: model:ir.model,name:website_partner_directory.model_res_partner
|
||||||
|
msgid "Contact"
|
||||||
|
msgstr "Contacto"
|
||||||
|
|
||||||
|
#. module: website_partner_directory
|
||||||
|
#: model:ir.model.fields,help:website_partner_directory.field_res_partner__show_in_directory
|
||||||
|
#: model:ir.model.fields,help:website_partner_directory.field_res_users__show_in_directory
|
||||||
|
msgid "If checked, this contact will appear in the public directory."
|
||||||
|
msgstr ""
|
||||||
|
"Si está marcada, este contacto aparecerá en el directorio público."
|
||||||
|
|
||||||
|
#. module: website_partner_directory
|
||||||
|
#: model_terms:ir.ui.view,arch_db:website_partner_directory.directory_page
|
||||||
|
msgid ""
|
||||||
|
"In this section you will find a list of companies registered in our "
|
||||||
|
"observatory."
|
||||||
|
msgstr ""
|
||||||
|
"En esta sección encontrará una lista de las empresas registradas en "
|
||||||
|
"nuestro observatorio."
|
||||||
|
|
||||||
|
#. module: website_partner_directory
|
||||||
|
#: model:ir.model.fields,field_description:website_partner_directory.field_res_partner__show_in_directory
|
||||||
|
#: model:ir.model.fields,field_description:website_partner_directory.field_res_users__show_in_directory
|
||||||
|
msgid "Show in directory"
|
||||||
|
msgstr "Mostrar en observatorio web"
|
||||||
50
website_partner_directory/i18n/website_partner_directory.pot
Normal file
50
website_partner_directory/i18n/website_partner_directory.pot
Normal file
|
|
@ -0,0 +1,50 @@
|
||||||
|
# Translation of Odoo Server.
|
||||||
|
# This file contains the translation of the following modules:
|
||||||
|
# * website_partner_directory
|
||||||
|
#
|
||||||
|
msgid ""
|
||||||
|
msgstr ""
|
||||||
|
"Project-Id-Version: Odoo Server 17.0\n"
|
||||||
|
"Report-Msgid-Bugs-To: \n"
|
||||||
|
"POT-Creation-Date: 2025-08-14 15:55+0000\n"
|
||||||
|
"PO-Revision-Date: 2025-08-14 15:55+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: website_partner_directory
|
||||||
|
#: model_terms:ir.ui.view,arch_db:website_partner_directory.directory_page
|
||||||
|
msgid "Company List"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#. module: website_partner_directory
|
||||||
|
#: model_terms:ir.ui.view,arch_db:website_partner_directory.directory_page
|
||||||
|
msgid "Company Observatory"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#. module: website_partner_directory
|
||||||
|
#: model:ir.model,name:website_partner_directory.model_res_partner
|
||||||
|
msgid "Contact"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#. module: website_partner_directory
|
||||||
|
#: model:ir.model.fields,help:website_partner_directory.field_res_partner__show_in_directory
|
||||||
|
#: model:ir.model.fields,help:website_partner_directory.field_res_users__show_in_directory
|
||||||
|
msgid "If checked, this contact will appear in the public directory."
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#. module: website_partner_directory
|
||||||
|
#: model_terms:ir.ui.view,arch_db:website_partner_directory.directory_page
|
||||||
|
msgid ""
|
||||||
|
"In this section you will find a list of companies registered in our "
|
||||||
|
"observatory."
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#. module: website_partner_directory
|
||||||
|
#: model:ir.model.fields,field_description:website_partner_directory.field_res_partner__show_in_directory
|
||||||
|
#: model:ir.model.fields,field_description:website_partner_directory.field_res_users__show_in_directory
|
||||||
|
msgid "Show in directory"
|
||||||
|
msgstr ""
|
||||||
1
website_partner_directory/models/__init__.py
Normal file
1
website_partner_directory/models/__init__.py
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
from . import res_partner
|
||||||
10
website_partner_directory/models/res_partner.py
Normal file
10
website_partner_directory/models/res_partner.py
Normal file
|
|
@ -0,0 +1,10 @@
|
||||||
|
from odoo import models, fields
|
||||||
|
|
||||||
|
|
||||||
|
class ResPartner(models.Model):
|
||||||
|
_inherit = "res.partner"
|
||||||
|
|
||||||
|
show_in_directory = fields.Boolean(
|
||||||
|
string="Show in directory",
|
||||||
|
help="If checked, this contact will appear in the public directory.",
|
||||||
|
)
|
||||||
44
website_partner_directory/views/directory_template.xml
Normal file
44
website_partner_directory/views/directory_template.xml
Normal file
|
|
@ -0,0 +1,44 @@
|
||||||
|
<odoo>
|
||||||
|
<template id="directory_page" name="Company Observatory">
|
||||||
|
<t t-call="website.layout">
|
||||||
|
<script src="https://unpkg.com/leaflet/dist/leaflet.js"></script>
|
||||||
|
|
||||||
|
<div class="container mt-4">
|
||||||
|
<h1>Company Observatory</h1>
|
||||||
|
|
||||||
|
<div id="partner_map" t-att-data-partners="json.dumps([
|
||||||
|
{'lat': p.partner_latitude, 'lon': p.partner_longitude, 'name': p.name}
|
||||||
|
for p in partners if p.partner_latitude and p.partner_longitude
|
||||||
|
])" style="height:500px;"></div>
|
||||||
|
|
||||||
|
<!-- Listado -->
|
||||||
|
<div class="mt-4 mb-3">
|
||||||
|
<h2>Company List</h2>
|
||||||
|
<p>In this section you will find a list of companies registered in our observatory.</p>
|
||||||
|
<ul class="list-group mb-5">
|
||||||
|
<t t-foreach="partners" t-as="partner">
|
||||||
|
<li class="list-group-item">
|
||||||
|
<strong><t t-out="partner.name"/></strong>
|
||||||
|
<t t-if="partner.city"> - <t t-out="partner.city"/></t>
|
||||||
|
</li>
|
||||||
|
</t>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
<script type="text/javascript">
|
||||||
|
window.addEventListener("load", function() {
|
||||||
|
const mapEl = document.getElementById('partner_map');
|
||||||
|
const partners = mapEl.dataset.partners ? JSON.parse(mapEl.dataset.partners) : [];
|
||||||
|
const map = L.map(mapEl).setView([40.4168, -3.7038], 6);
|
||||||
|
L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', { maxZoom: 19 }).addTo(map);
|
||||||
|
|
||||||
|
<t t-foreach="partners" t-as="partner">
|
||||||
|
L.marker([<t t-out="partner.partner_latitude"/>, <t t-out="partner.partner_longitude"/>])
|
||||||
|
.addTo(map)
|
||||||
|
.bindPopup("<strong><t t-out='partner.name'/></strong>");
|
||||||
|
</t>
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
</div>
|
||||||
|
</t>
|
||||||
|
</template>
|
||||||
|
</odoo>
|
||||||
12
website_partner_directory/views/res_partner_views.xml
Normal file
12
website_partner_directory/views/res_partner_views.xml
Normal file
|
|
@ -0,0 +1,12 @@
|
||||||
|
<odoo>
|
||||||
|
<record id="view_partner_form_directory" model="ir.ui.view">
|
||||||
|
<field name="name">res.partner.form.directory</field>
|
||||||
|
<field name="model">res.partner</field>
|
||||||
|
<field name="inherit_id" ref="base.view_partner_form"/>
|
||||||
|
<field name="arch" type="xml">
|
||||||
|
<xpath expr="//field[@name='website']" position="after">
|
||||||
|
<field name="show_in_directory"/>
|
||||||
|
</xpath>
|
||||||
|
</field>
|
||||||
|
</record>
|
||||||
|
</odoo>
|
||||||
Loading…
Add table
Add a link
Reference in a new issue