├── README.md ├── cron ├── static │ └── description │ │ ├── icon.png │ │ ├── support.png │ │ └── index.html ├── cron_view.xml ├── __init__.py ├── wizard │ ├── __init__.py │ ├── start_cron.py │ └── start_cron_view.xml └── __manifest__.py └── web_map ├── static ├── description │ ├── icon.png │ ├── map.png │ ├── api_key.png │ ├── support.png │ └── index.html └── src │ ├── css │ └── web_map.css │ ├── xml │ └── web_map.xml │ └── js │ └── web_map.js ├── __init__.py ├── models ├── __init__.py ├── ir_http.py └── res_config.py ├── views ├── web_map_templates.xml └── res_config_views.xml └── __manifest__.py /README.md: -------------------------------------------------------------------------------- 1 | Tools 2 | ===== 3 | 4 | Some tools for Odoo 5 | -------------------------------------------------------------------------------- /cron/static/description/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codup/odoo-tools/HEAD/cron/static/description/icon.png -------------------------------------------------------------------------------- /cron/static/description/support.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codup/odoo-tools/HEAD/cron/static/description/support.png -------------------------------------------------------------------------------- /web_map/static/description/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codup/odoo-tools/HEAD/web_map/static/description/icon.png -------------------------------------------------------------------------------- /web_map/static/description/map.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codup/odoo-tools/HEAD/web_map/static/description/map.png -------------------------------------------------------------------------------- /web_map/static/description/api_key.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codup/odoo-tools/HEAD/web_map/static/description/api_key.png -------------------------------------------------------------------------------- /web_map/static/description/support.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codup/odoo-tools/HEAD/web_map/static/description/support.png -------------------------------------------------------------------------------- /web_map/static/src/css/web_map.css: -------------------------------------------------------------------------------- 1 | .codup_gmap 2 | { 3 | margin-top: 16px; 4 | padding-left: 100%; 5 | padding-bottom: 56.25%; 6 | } -------------------------------------------------------------------------------- /web_map/static/src/xml/web_map.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 |
5 |
6 |
-------------------------------------------------------------------------------- /cron/cron_view.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /cron/__init__.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | ############################################################################## 3 | # 4 | # Odoo 5 | # Copyright (C) 2014-2018 CodUP (). 6 | # 7 | ############################################################################## 8 | 9 | from . import wizard 10 | -------------------------------------------------------------------------------- /cron/wizard/__init__.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | ############################################################################## 3 | # 4 | # Odoo 5 | # Copyright (C) 2014-2018 CodUP (). 6 | # 7 | ############################################################################## 8 | 9 | from . import start_cron 10 | -------------------------------------------------------------------------------- /web_map/__init__.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | ############################################################################## 3 | # 4 | # Odoo 5 | # Copyright (C) 2017-2018 CodUP (). 6 | # 7 | ############################################################################## 8 | 9 | from . import models 10 | 11 | # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: -------------------------------------------------------------------------------- /web_map/models/__init__.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | ############################################################################## 3 | # 4 | # Odoo 5 | # Copyright (C) 2017-2018 CodUP (). 6 | # 7 | ############################################################################## 8 | 9 | from . import ir_http 10 | from . import res_config 11 | 12 | # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: -------------------------------------------------------------------------------- /cron/wizard/start_cron.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | ############################################################################## 3 | # 4 | # Odoo 5 | # Copyright (C) 2014-2018 CodUP (). 6 | # 7 | ############################################################################## 8 | 9 | from odoo.service.server import ThreadedServer 10 | from odoo import api, fields, models 11 | 12 | 13 | class cron_start_cron(models.TransientModel): 14 | _name = 'cron.start.cron' 15 | _description = 'Start cron' 16 | 17 | def start_cron(self): 18 | ThreadedServer(None).cron_spawn() 19 | return {'type': 'ir.actions.act_window_close',} 20 | -------------------------------------------------------------------------------- /web_map/views/web_map_templates.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 14 | -------------------------------------------------------------------------------- /web_map/models/ir_http.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | ############################################################################## 3 | # 4 | # Odoo 5 | # Copyright (C) 2017 CodUP (). 6 | # 7 | ############################################################################## 8 | 9 | from odoo import models 10 | from odoo.http import request 11 | 12 | 13 | class Http(models.AbstractModel): 14 | _inherit = 'ir.http' 15 | 16 | def webclient_rendering_context(self): 17 | rendering_context = super(Http, self).webclient_rendering_context() 18 | rendering_context['google_maps_api_key'] = request.env['ir.config_parameter'].sudo().get_param('google_maps_api_key') 19 | return rendering_context 20 | 21 | # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: -------------------------------------------------------------------------------- /cron/__manifest__.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | ############################################################################## 3 | # 4 | # Odoo 5 | # Copyright (C) 2014-2018 CodUP (). 6 | # 7 | ############################################################################## 8 | 9 | { 10 | 'name': 'Cron', 11 | 'version': '2.2', 12 | 'category': 'Extra Tools', 13 | 'summary': 'WSGI cron control', 14 | 'description': """ 15 | WSGI cron control 16 | ----------------- 17 | User interface for manually start cron. 18 | Usefull if you use WSGI deployment. 19 | """, 20 | 'author': 'CodUP', 21 | 'website': 'http://codup.com', 22 | 'depends': [], 23 | 'demo': [], 24 | 'data': [ 25 | 'wizard/start_cron_view.xml', 26 | 'cron_view.xml', 27 | ], 28 | 'installable': True, 29 | } 30 | -------------------------------------------------------------------------------- /web_map/models/res_config.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | ############################################################################## 3 | # 4 | # Odoo 5 | # Copyright (C) 2017-2018 CodUP (). 6 | # 7 | ############################################################################## 8 | 9 | from odoo import api, fields, models 10 | 11 | 12 | class ResConfigSettings(models.TransientModel): 13 | _inherit = 'res.config.settings' 14 | 15 | google_maps_api_key = fields.Char('Google Maps API Key') 16 | 17 | def set_values(self): 18 | super(ResConfigSettings, self).set_values() 19 | set_param = self.env['ir.config_parameter'].set_param 20 | set_param('google_maps_api_key', (self.google_maps_api_key or '').strip()) 21 | 22 | @api.model 23 | def get_values(self): 24 | res = super(ResConfigSettings, self).get_values() 25 | get_param = self.env['ir.config_parameter'].sudo().get_param 26 | res.update( 27 | google_maps_api_key=get_param('google_maps_api_key', default=''), 28 | ) 29 | return res 30 | -------------------------------------------------------------------------------- /web_map/__manifest__.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | ############################################################################## 3 | # 4 | # Odoo 5 | # Copyright (C) 2017-2018 CodUP (). 6 | # 7 | ############################################################################## 8 | 9 | { 10 | 'name': 'Web Map', 11 | 'version': '0.3', 12 | 'category': 'Extra Tools', 13 | 'summary': 'Map widget', 14 | 'description': """ 15 | Odoo Web Map view 16 | ========================== 17 | Support following feature: 18 | * Google Maps widget 19 | * Add multiple maps to form view 20 | * Readonly mode 21 | * Edit mode 22 | """, 23 | 'author': 'CodUP', 24 | 'license': 'AGPL-3', 25 | 'website': 'http://codup.com', 26 | 'sequence': 0, 27 | 'depends': ['base_setup','web'], 28 | 'data': [ 29 | 'views/web_map_templates.xml', 30 | 'views/res_config_views.xml', 31 | ], 32 | 'qweb': [ 33 | 'static/src/xml/*.xml', 34 | ], 35 | 'installable': True, 36 | } 37 | # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: -------------------------------------------------------------------------------- /cron/static/description/index.html: -------------------------------------------------------------------------------- 1 |
2 |
3 |

WSGI cron control

4 |
5 |

6 | User interface for manually start cron. 7 | Usefull if you use WSGI deployment. 8 |

9 |
10 |
11 |
12 | 13 |
14 |
15 |

Help and Support

16 |
17 |
18 | 19 |
20 |
21 |
22 |

23 |

28 |

29 |
30 |
31 |
-------------------------------------------------------------------------------- /cron/wizard/start_cron_view.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Start cron 7 | cron.start.cron 8 | 9 |
10 | 11 |
17 |
18 | 19 | 20 | Start cron 21 | ir.actions.act_window 22 | cron.start.cron 23 | form 24 | form 25 | new 26 | 27 | 28 |
29 |
-------------------------------------------------------------------------------- /web_map/views/res_config_views.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Map_settings 5 | res.config.settings 6 | 7 | 8 | 9 |
10 |
11 | Google Maps 12 |
13 | Follow the instructions to create your key. 14 |
15 |
16 |
17 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
-------------------------------------------------------------------------------- /web_map/static/description/index.html: -------------------------------------------------------------------------------- 1 |
2 |
3 |

Odoo Web Map view

4 |
5 |

6 | Map widget. 7 |

8 |

9 | Support following features: 10 |

    11 |
  • Google Maps widget
  • 12 |
  • Add multiple maps to form view
  • 13 |
  • Readonly mode
  • 14 |
  • Edit mode
  • 15 |
16 |

17 |
18 |
19 |
20 | 21 |
22 |
23 |

Demo Server

24 |
25 | 26 | 27 | 28 |
29 |

login: codup / password: codup

30 |
31 |
32 | 33 |
34 |
35 |

How use

36 |
37 |

Just add attribute widget="map" to your field. 38 |

39 |

Don't forget save your Google Maps API Key in [Settings/General Settings]. 40 |

41 |
42 |
43 |
44 | 45 |
46 |
47 |
48 |
49 | 50 |
51 |
52 |

Help and Support

53 |
54 |
55 | 56 |
57 |
58 |
59 |

60 |

65 |

66 |
67 |
68 |
-------------------------------------------------------------------------------- /web_map/static/src/js/web_map.js: -------------------------------------------------------------------------------- 1 | odoo.define('web_map.FieldMap', function(require) { 2 | "use strict"; 3 | 4 | var field_registry = require('web.field_registry'); 5 | var AbstractField = require('web.AbstractField'); 6 | 7 | var FormController = require('web.FormController'); 8 | 9 | FormController.include({ 10 | _update: function () { 11 | var _super_update = this._super.apply(this, arguments); 12 | this.trigger('view_updated'); 13 | return _super_update; 14 | }, 15 | }); 16 | 17 | var FieldMap = AbstractField.extend({ 18 | template: 'FieldMap', 19 | start: function() { 20 | var self = this; 21 | 22 | this.getParent().getParent().on('view_updated', self, function() { 23 | self.update_map(); 24 | self.getParent().$('a[data-toggle="tab"]').on('shown.bs.tab', function() { 25 | self.update_map(); 26 | }); 27 | }); 28 | return this._super(); 29 | }, 30 | update_mode: function() { 31 | if(this.isMap) { 32 | if(this.mode === 'readonly') { 33 | this.map.setOptions({ 34 | disableDoubleClickZoom: true, 35 | draggable: false, 36 | scrollwheel: false, 37 | }); 38 | this.marker.setOptions({ 39 | draggable: false, 40 | cursor: 'default', 41 | }); 42 | } else { 43 | this.map.setOptions({ 44 | disableDoubleClickZoom: false, 45 | draggable: true, 46 | scrollwheel: true, 47 | }); 48 | this.marker.setOptions({ 49 | draggable: true, 50 | cursor: 'pointer', 51 | }); 52 | } 53 | } 54 | }, 55 | update_map: function() { 56 | if(!this.isMap && this.el.offsetWidth > 0) { 57 | this.init_map(); 58 | this.isMap = true; 59 | } 60 | this.update_mode(); 61 | }, 62 | init_map: function() { 63 | var self = this; 64 | 65 | this.map = new google.maps.Map(this.el, { 66 | center: {lat:0,lng:0}, 67 | zoom: 2, 68 | disableDefaultUI: true, 69 | }); 70 | this.marker = new google.maps.Marker({ 71 | position: {lat:0,lng:0}, 72 | }); 73 | 74 | if(this.value) { 75 | this.marker.setPosition(JSON.parse(this.value).position); 76 | this.map.setCenter(JSON.parse(this.value).position); 77 | this.map.setZoom(JSON.parse(this.value).zoom); 78 | this.marker.setMap(this.map); 79 | } 80 | 81 | this.map.addListener('click', function(e) { 82 | if(self.mode === 'edit' && self.marker.getMap() == null) { 83 | self.marker.setPosition(e.latLng); 84 | self.marker.setMap(self.map); 85 | self._setValue(JSON.stringify({position:self.marker.getPosition(),zoom:self.map.getZoom()})); 86 | } 87 | }); 88 | this.map.addListener('zoom_changed', function() { 89 | if(self.mode === 'edit' && self.marker.getMap()) { 90 | self._setValue(JSON.stringify({position:self.marker.getPosition(),zoom:self.map.getZoom()})); 91 | } 92 | }); 93 | this.marker.addListener('click', function() { 94 | if(self.mode === 'edit') { 95 | self.marker.setMap(null); 96 | self._setValue(false); 97 | } 98 | }); 99 | this.marker.addListener('dragend', function() { 100 | self._setValue(JSON.stringify({position:self.marker.getPosition(),zoom:self.map.getZoom()})); 101 | }); 102 | }, 103 | }); 104 | 105 | field_registry.add('map', FieldMap); 106 | 107 | return { 108 | FieldMap: FieldMap, 109 | }; 110 | 111 | }); --------------------------------------------------------------------------------