-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
17 changed files
with
907 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
from . import models |
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,28 @@ | ||
# -*- coding: utf-8 -*- | ||
# Copyright 2024-2024 Felix Coca | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
|
||
{ | ||
'name': "Widget Map", | ||
'summary': "Allow to use a map location as widget on the form views.", | ||
"version": "17.0.1.0.0", | ||
"license": "AGPL-3", | ||
'author': "Felix Coca", | ||
'website': "https://grandbastion.dev", | ||
'category': 'Web', | ||
'depends': ['web'], | ||
'assets': { | ||
'web.assets_backend': [ | ||
'map_field/static/src/components/**/*', | ||
'map_field/static/src/css/map.scss', | ||
], | ||
'web.assets_common': [ | ||
|
||
], | ||
'web.qunit_suite_tests': [ | ||
#'map_field/static/src/js/webclient_tests.js', | ||
] | ||
}, | ||
'license': 'AGPL-3', | ||
} | ||
|
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,3 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
from . import map |
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,52 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
from odoo.fields import Field | ||
|
||
|
||
class Map(Field): | ||
""" | ||
Map Widget | ||
This new field type is used to store a Google Map location. | ||
The field is stored as a text field in the database, and the value is a string in the format: | ||
"latitude,longitude" | ||
where latitude and longitude are float values. | ||
The field is displayed as a map in the form view, and the user can click on the map to set the location. | ||
The field is displayed as a link in the tree view, and the user can click on the link to open the location in Google Maps. | ||
The field is displayed as a map in the Kanban view, and the user can click on the map to set the location. | ||
""" | ||
|
||
type = "point" | ||
# Postgresql column type https://www.postgresql.org/docs/current/datatype.html | ||
column_type = ("point", "point") | ||
|
||
def _get_attrs(self, model_class, name): | ||
res = super()._get_attrs(model_class, name) | ||
return res | ||
|
||
def convert_to_record(self, value, record, validate=True): | ||
return value or None | ||
|
||
def _update(self, records, value): | ||
cache = records.env.cache | ||
for record in records: | ||
cache.set(record, self, value.id or None) | ||
|
||
def convert_to_export(self, value, record): | ||
return value or None | ||
|
||
@staticmethod | ||
def to_lat_lon(value: str): | ||
""" | ||
Parse the value "(latitude, longitude)" to a tuple (latitude, longitude) | ||
""" | ||
if value: | ||
res = value.replace("(").replace(")").split(",") | ||
return float(res[0]), float(res[1]) | ||
return None |
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,3 @@ | ||
[build-system] | ||
requires = ["whool"] | ||
build-backend = "whool.buildapi" |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.