add website_partner_directory

This commit is contained in:
Luis 2025-08-14 18:06:43 +02:00
commit 9cabf044c8
12 changed files with 275 additions and 0 deletions

56
.gitignore vendored Normal file
View 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

View file

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

View 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",
}

View file

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

View 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,
},
)

Binary file not shown.

View 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"

View 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 ""

View file

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

View 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.",
)

View 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>

View 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>