-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #85 from INRIM/t_12426
[UPD] added geo_localize on ca.persona
- Loading branch information
Showing
6 changed files
with
314 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
131 changes: 128 additions & 3 deletions
131
inrim_controllo_accessi_custom/i18n/it.po
100755 → 100644
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,140 @@ | ||
# Translation of Odoo Server. | ||
# This file contains the translation of the following modules: | ||
# * inrim_controllo_accessi_custom | ||
# | ||
msgid "" | ||
msgstr "" | ||
"Project-Id-Version: Odoo Server 17.0\n" | ||
"Project-Id-Version: Odoo Server 17.0+e\n" | ||
"Report-Msgid-Bugs-To: \n" | ||
"POT-Creation-Date: 2024-05-07 08:30+0000\n" | ||
"PO-Revision-Date: 2024-05-07 08:30+0000\n" | ||
"POT-Creation-Date: 2024-09-18 08:35+0000\n" | ||
"PO-Revision-Date: 2024-09-18 08:35+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: inrim_controllo_accessi_custom | ||
#: model_terms:ir.ui.view,arch_db:inrim_controllo_accessi_custom.ca_persona_view_form_inherit_geolocation | ||
msgid "Compute Localization" | ||
msgstr "Calcola Geolocalizzazione" | ||
|
||
#. module: inrim_controllo_accessi_custom | ||
#: model_terms:ir.ui.view,arch_db:inrim_controllo_accessi_custom.ca_persona_view_form_inherit_geolocation | ||
msgid "Compute based on domicile address" | ||
msgstr "Calcola in base all'indirizzo di domicilio" | ||
|
||
#. module: inrim_controllo_accessi_custom | ||
#: model_terms:ir.ui.view,arch_db:inrim_controllo_accessi_custom.ca_persona_view_form_inherit_geolocation | ||
msgid "Compute based on residence address" | ||
msgstr "Calcola in base all'indirizzo di residenza" | ||
|
||
#. module: inrim_controllo_accessi_custom | ||
#: model_terms:ir.ui.view,arch_db:inrim_controllo_accessi_custom.ca_persona_view_form_inherit_geolocation | ||
msgid "Domicile Geolocation" | ||
msgstr "Geolocalizzazione Domicilio" | ||
|
||
#. module: inrim_controllo_accessi_custom | ||
#: model:ir.model,name:inrim_controllo_accessi_custom.model_ca_ente_azienda | ||
msgid "Ente Azienda" | ||
msgstr "" | ||
|
||
#. module: inrim_controllo_accessi_custom | ||
#: model:ir.model.fields,field_description:inrim_controllo_accessi_custom.field_ca_persona__domicile_partner_latitude | ||
#: model:ir.model.fields,field_description:inrim_controllo_accessi_custom.field_ca_persona__residence_partner_latitude | ||
msgid "Geo Latitude" | ||
msgstr "" | ||
|
||
#. module: inrim_controllo_accessi_custom | ||
#: model:ir.model.fields,field_description:inrim_controllo_accessi_custom.field_ca_persona__domicile_partner_longitude | ||
#: model:ir.model.fields,field_description:inrim_controllo_accessi_custom.field_ca_persona__residence_partner_longitude | ||
msgid "Geo Longitude" | ||
msgstr "" | ||
|
||
#. module: inrim_controllo_accessi_custom | ||
#: model:ir.model.fields,field_description:inrim_controllo_accessi_custom.field_ca_persona__domicile_date_localization | ||
#: model:ir.model.fields,field_description:inrim_controllo_accessi_custom.field_ca_persona__residence_date_localization | ||
msgid "Geolocation Date" | ||
msgstr "Data geolocalizzazione" | ||
|
||
#. module: inrim_controllo_accessi_custom | ||
#: model:ir.model.fields,field_description:inrim_controllo_accessi_custom.field_ca_ente_azienda__jwt | ||
msgid "Jwt" | ||
msgstr "" | ||
|
||
#. module: inrim_controllo_accessi_custom | ||
#: model_terms:ir.ui.view,arch_db:inrim_controllo_accessi_custom.ca_persona_view_form_inherit_geolocation | ||
msgid "Lat :" | ||
msgstr "" | ||
|
||
#. module: inrim_controllo_accessi_custom | ||
#: model:ir.model.fields,field_description:inrim_controllo_accessi_custom.field_ca_ente_azienda__lock | ||
msgid "Lock" | ||
msgstr "" | ||
|
||
#. module: inrim_controllo_accessi_custom | ||
#: model_terms:ir.ui.view,arch_db:inrim_controllo_accessi_custom.ca_persona_view_form_inherit_geolocation | ||
msgid "Long:" | ||
msgstr "" | ||
|
||
#. module: inrim_controllo_accessi_custom | ||
#. odoo-python | ||
#: code:addons/inrim_controllo_accessi_custom/models/ca_persona.py:0 | ||
#: code:addons/inrim_controllo_accessi_custom/models/ca_persona.py:0 | ||
#, python-format | ||
msgid "No match found for %(partner_names)s address(es)." | ||
msgstr "Nessuna corrispondenza individuata per gli indirizzi di %(partner_names)s." | ||
|
||
#. module: inrim_controllo_accessi_custom | ||
#: model:ir.model.fields,field_description:inrim_controllo_accessi_custom.field_ca_ente_azienda__nome_chiave_header | ||
msgid "Nome Chiave Header" | ||
msgstr "" | ||
|
||
#. module: inrim_controllo_accessi_custom | ||
#: model_terms:ir.ui.view,arch_db:inrim_controllo_accessi_custom.ca_persona_view_form_inherit_geolocation | ||
msgid "Partner Geolocation" | ||
msgstr "" | ||
|
||
#. module: inrim_controllo_accessi_custom | ||
#: model:ir.model,name:inrim_controllo_accessi_custom.model_ca_persona | ||
msgid "Persona" | ||
msgstr "Anagrafica Persona" | ||
|
||
#. module: inrim_controllo_accessi_custom | ||
#: model:ir.model.fields,field_description:inrim_controllo_accessi_custom.field_ca_ente_azienda__ref | ||
msgid "Ref" | ||
msgstr "" | ||
|
||
#. module: inrim_controllo_accessi_custom | ||
#: model_terms:ir.ui.view,arch_db:inrim_controllo_accessi_custom.ca_persona_view_form_inherit_geolocation | ||
msgid "Refresh" | ||
msgstr "Aggiorna" | ||
|
||
#. module: inrim_controllo_accessi_custom | ||
#: model_terms:ir.ui.view,arch_db:inrim_controllo_accessi_custom.ca_persona_view_form_inherit_geolocation | ||
msgid "Refresh Localization" | ||
msgstr "Ricarica Geolocalizzazione" | ||
|
||
#. module: inrim_controllo_accessi_custom | ||
#: model_terms:ir.ui.view,arch_db:inrim_controllo_accessi_custom.ca_persona_view_form_inherit_geolocation | ||
msgid "Residence Geolocation" | ||
msgstr "Geolocalizzazione Residenza" | ||
|
||
#. module: inrim_controllo_accessi_custom | ||
#: model_terms:ir.ui.view,arch_db:inrim_controllo_accessi_custom.ca_persona_view_form_inherit_geolocation | ||
msgid "Updated on:" | ||
msgstr "Aggiornato il:" | ||
|
||
#. module: inrim_controllo_accessi_custom | ||
#: model:ir.model.fields,field_description:inrim_controllo_accessi_custom.field_ca_ente_azienda__url_gateway_lettori | ||
msgid "Url Gateway Lettori" | ||
msgstr "" | ||
|
||
#. module: inrim_controllo_accessi_custom | ||
#. odoo-python | ||
#: code:addons/inrim_controllo_accessi_custom/models/ca_persona.py:0 | ||
#: code:addons/inrim_controllo_accessi_custom/models/ca_persona.py:0 | ||
#, python-format | ||
msgid "Warning" | ||
msgstr "Attenzione" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
from . import ente_azienda | ||
from . import ente_azienda | ||
from . import ca_persona |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
from odoo import api, fields, models, _ | ||
from odoo.tools import config | ||
|
||
class CaPersona(models.Model): | ||
_inherit = 'ca.persona' | ||
|
||
domicile_partner_latitude = fields.Float(string='Geo Latitude', digits=(10, 7)) | ||
domicile_partner_longitude = fields.Float(string='Geo Longitude', digits=(10, 7)) | ||
domicile_date_localization = fields.Date(string='Geolocation Date') | ||
residence_partner_latitude = fields.Float(string='Geo Latitude', digits=(10, 7)) | ||
residence_partner_longitude = fields.Float(string='Geo Longitude', digits=(10, 7)) | ||
residence_date_localization = fields.Date(string='Geolocation Date') | ||
|
||
def write(self, vals): | ||
# Reset latitude/longitude in case we modify the address without | ||
# updating the related geolocation fields | ||
if any(field in vals for field in [ | ||
'domicile_street', 'domicile_zip','domicile_city', | ||
'domicile_state_id', 'domicile_country_id' | ||
]) \ | ||
and not all('partner_%s' % field in vals for field in ['latitude', 'longitude']): | ||
vals.update({ | ||
'domicile_partner_latitude': 0.0, | ||
'domicile_partner_longitude': 0.0, | ||
}) | ||
if any(field in vals for field in [ | ||
'residence_street', 'residence_zip', 'residence_city', | ||
'residence_state_id', 'residence_country_id' | ||
]) \ | ||
and not all('partner_%s' % field in vals for field in ['latitude', 'longitude']): | ||
vals.update({ | ||
'residence_partner_latitude': 0.0, | ||
'residence_partner_longitude': 0.0, | ||
}) | ||
return super(CaPersona, self).write(vals) | ||
|
||
@api.model | ||
def _geo_localize(self, street='', zip='', city='', state='', country=''): | ||
geo_obj = self.env['base.geocoder'] | ||
search = geo_obj.geo_query_address(street=street, zip=zip, city=city, state=state, country=country) | ||
result = geo_obj.geo_find(search, force_country=country) | ||
if result is None: | ||
search = geo_obj.geo_query_address(city=city, state=state, country=country) | ||
result = geo_obj.geo_find(search, force_country=country) | ||
return result | ||
|
||
def geo_localize(self): | ||
# We need country names in English below | ||
if not self._context.get('force_geo_localize') \ | ||
and (self._context.get('import_file') \ | ||
or any(config[key] for key in ['test_enable', 'test_file', 'init', 'update'])): | ||
return False | ||
partners_not_geo_localized = self.env['ca.persona'] | ||
address_type = self._context.get('address_type') | ||
if address_type in ['domicile', 'residence']: | ||
for partner in self.with_context(lang='en_US'): | ||
if address_type == 'domicile': | ||
result = self._geo_localize(partner.domicile_street, | ||
partner.domicile_zip, | ||
partner.domicile_city, | ||
partner.domicile_state_id.name, | ||
partner.domicile_country_id.name) | ||
elif address_type == 'residence': | ||
result = self._geo_localize(partner.residence_street, | ||
partner.residence_zip, | ||
partner.residence_city, | ||
partner.residence_state_id.name, | ||
partner.residence_country_id.name) | ||
if result: | ||
partner.write({ | ||
f'{address_type}_partner_latitude': result[0], | ||
f'{address_type}_partner_longitude': result[1], | ||
f'{address_type}_date_localization': fields.Date.context_today(partner) | ||
}) | ||
else: | ||
partners_not_geo_localized |= partner | ||
if partners_not_geo_localized: | ||
self.env['bus.bus']._sendone(self.env.user.partner_id, 'simple_notification', { | ||
'title': _("Warning"), | ||
'message': _('No match found for %(partner_names)s address(es).', partner_names=', '.join(partners_not_geo_localized.mapped('display_name'))) | ||
}) | ||
return True |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<odoo> | ||
<record id="ca_persona_view_form_inherit_geolocation" model="ir.ui.view"> | ||
<field name="name">ca.persona.view.form.inherit</field> | ||
<field name="model">ca.persona</field> | ||
<field name="inherit_id" ref="inrim_anagrafiche.ca_persona_form"/> | ||
<field name="arch" type="xml"> | ||
<xpath expr="//t//page[@name='identity_documents']" position="after"> | ||
<page string="Partner Geolocation" name="geo_location"> | ||
<group> | ||
<group string="Domicile Geolocation"> | ||
<label for="domicile_date_localization" string="Domicile Geolocation"/> | ||
<div> | ||
<span>Lat : <field name="domicile_partner_latitude" readonly="1" nolabel="1" class="oe_inline"/></span> | ||
<br/> | ||
<span>Long: <field name="domicile_partner_longitude" readonly="1" nolabel="1" class="oe_inline"/></span> | ||
<br/> | ||
<span invisible="not domicile_date_localization">Updated on: | ||
<field name="domicile_date_localization" nolabel="1" readonly="1" class="oe_inline"/> | ||
<br/> | ||
</span> | ||
</div> | ||
</group> | ||
<group string="Residence Geolocation" invisible="not domicile_other_than_residence"> | ||
<label for="residence_date_localization" string="Residence Geolocation"/> | ||
<div> | ||
<span>Lat : <field name="residence_partner_latitude" readonly="1" nolabel="1" class="oe_inline"/></span> | ||
<br/> | ||
<span>Long: <field name="residence_partner_longitude" readonly="1" nolabel="1" class="oe_inline"/></span> | ||
<br/> | ||
<span invisible="not residence_date_localization">Updated on: | ||
<field name="residence_date_localization" nolabel="1" readonly="1" class="oe_inline"/> | ||
<br/> | ||
</span> | ||
</div> | ||
</group> | ||
</group> | ||
</page> | ||
</xpath> | ||
<xpath expr="//t[2]//page[@name='identity_documents']" position="after"> | ||
<page string="Partner Geolocation" name="geo_location"> | ||
<group> | ||
<group string="Domicile Geolocation"> | ||
<label for="domicile_date_localization" string="Domicile Geolocation"/> | ||
<div> | ||
<span>Lat : <field name="domicile_partner_latitude" nolabel="1" class="oe_inline"/></span> | ||
<br/> | ||
<span>Long: <field name="domicile_partner_longitude" nolabel="1" class="oe_inline"/></span> | ||
<br/> | ||
<span invisible="not domicile_date_localization">Updated on: | ||
<field name="domicile_date_localization" nolabel="1" readonly="1" class="oe_inline"/> | ||
<br/> | ||
</span> | ||
<button invisible="domicile_partner_latitude != 0 or domicile_partner_longitude != 0" | ||
icon="fa-gear" string="Compute based on domicile address" title="Compute Localization" | ||
name="geo_localize" type="object" class="btn btn-link p-0" | ||
context="{'address_type': 'domicile'}"/> | ||
<button invisible="not domicile_partner_latitude and not domicile_partner_longitude" | ||
icon="fa-refresh" string="Refresh" title="Refresh Localization" | ||
name="geo_localize" type="object" class="btn btn-link p-0" | ||
context="{'address_type': 'domicile'}"/> | ||
</div> | ||
</group> | ||
<group string="Residence Geolocation" invisible="not domicile_other_than_residence"> | ||
<label for="residence_date_localization" string="Residence Geolocation"/> | ||
<div> | ||
<span>Lat : <field name="residence_partner_latitude" nolabel="1" class="oe_inline"/></span> | ||
<br/> | ||
<span>Long: <field name="residence_partner_longitude" nolabel="1" class="oe_inline"/></span> | ||
<br/> | ||
<span invisible="not residence_date_localization">Updated on: | ||
<field name="residence_date_localization" nolabel="1" readonly="1" class="oe_inline"/> | ||
<br/> | ||
</span> | ||
<button invisible="residence_partner_latitude != 0 or residence_partner_longitude != 0" | ||
icon="fa-gear" string="Compute based on residence address" title="Compute Localization" | ||
name="geo_localize" type="object" class="btn btn-link p-0" | ||
context="{'address_type': 'residence'}"/> | ||
<button invisible="not residence_partner_latitude and not residence_partner_longitude" | ||
icon="fa-refresh" string="Refresh" title="Refresh Localization" | ||
name="geo_localize" type="object" class="btn btn-link p-0" | ||
context="{'address_type': 'residence'}"/> | ||
</div> | ||
</group> | ||
</group> | ||
</page> | ||
</xpath> | ||
</field> | ||
</record> | ||
</odoo> |