Search 1.9 billion lines of Odoo code on GitHub

web_google_maps

Author: Yopi Angi
License: AGPL-3
Branch: 15.0
Repository: SDIsl/geolocation
Dependencies: base, base_geolocalize, base_setup, and web
Languages: HTML (84, 1.5%), JavaScript (4047, 70.8%), Markdown (336, 5.9%), PO File (334, 5.8%), Python (360, 6.3%), Sass (255, 4.5%), and XML (297, 5.2%)
Other branches: 10.0, 11.0, 11.0-state_id, 12.0, 14.0, 9.0, master, and v1120171028
Other repositories: Andyeyo/Odoo-Addons, Bilbonet/odoo-addons, DITIntl/odoo-addons-1, GiraffosCom/odoo-cl-12, Gonscar88/odoo-addons, Guobower/Odoo-Addons-2, Idealisconsulting/odoo-addons, Infinityloopsistemas/odoo-addons, Kalway-Technology/odoo-addons, KurrufERP/odoo-cl-12, LevelPrime/odoo-google-maps, Loo-ERP/odoo-addons, Manuellama/odoo-addons, Mefistous/odoo-cl-12, NivasRaj/odoo-addons, Normatica/odoo-cl-12, NothingCtrl/odoo-addons, OdooBulgaria/Odoo-Addons-17, OdooBulgaria/odoo-addons-15, RL-OtherApps/odoo-addons-2, SantosJMM/odoo-addons, Sroeurnsuon/odoo-addons, TheCloneMaster/Odoo-Addons, UnknownInfo/odoo-cl-12, Vassy/odoo-addons, VizThoughts/odoo-addons-2, abdalmola-apps/odoo-addons, alvarojimenezpaz/odoo-cl-12, anhvu-sg/odoo-addons, aschenkels-ictstudio/odoo-addons-1, azizulj8/odoo-addons, be-cloud-be/odoo-addons, bgavarini/odoo-addons, bimajatiwijaya/odoo-addons, bishalgit/odoo-addons, brain-tec/odoo-addons, cameleonRuoi/odoo-addons, consultingerp/crm_maps-12, daemondev/Odoo-Addons, dansanti/odoo-addons, desiteg/odoo-addons, diegobgl/odoo-addons, dong-z/odoo-addons, dtka0105/odoo-addons, erick-alvino/odoo-addons-1, erlopezh/odoo-addons, flectra-chile/odoo-cl-12, fva-idealis/odoo-addons, gitstalker/odoo-addons-1, gityopie/odoo-addons, grupoebox/odoo-addons, guohuadeng/odoo-addons, gustotc/odoo-addons, halybang/odoo-addons, hashirharis/odoo-addons, hippe-67/odoo-addons, hoangpq/odoo-addons-web-gg, iledarn/odoo-addons, intellego-bi/odoo-12, intellego-bi/odoo-cl-12, iuppiterpluvius/odoo-addons, jason156/Odoo-Addons-4, jeffersonjeff/odoo-addons, josemoralesp/odoo-addons, jriveros/odoo-cl-12, katyukha/odoo-addons, killteck/odoo-addons, kit9/odoo-addons-2, leodoooca/gityopie-odoo-addons, litnimax/odoo-addons, marcel1981/odoo-cl-12, marcelomora/yopie, marcelsavegnago/odoo-addons-3, martinllanos/odoo-addons, maurolguin1/odoo-cl-12, mgielissen/odoo-addons-7, minhhq09/odoo-addons, nerkusoft/odoo-addons, nextmoveits/odoo-addons, nguyenductamlhp/odoo-addons, nick2474/odoo-addons-1, nikeshscs/odoo-addons, njeudy/odoo-addons, nknganda/odoo-addons, odoochain/odoo-addons, odoogap/odoo-addons, odoonz/misc-gityopie, ohernandez-getinsoft/odoo-addons, one2pret/odoo-addons, osvalr/Odoo-Addons, petypi/odoo-addons-2, pnajman-modoolar/odoo-addons, redcor/field-service, sadeqamin/odoo-addons, sc4you/odoo-addons-3, scbrianti/odoo-addons, sgheller/odoo-addons, sm2x/odoo-addons, spoerp/odoo-addons, t-np/odoo-addons, tate11/odoo-addons-6, thanhdongcntt/odoo-addons, udamuri/odoo-addons, ursais/odoo-addons, vidtsin/odoo-cl-12, wahello/odoo-addons, westlyou/Odoo-Addons-4, westlyou/odoo-addons-2, xpertiz/odoo-addons, zarumaru/odoo-addons, and zoubir/odoo-addons

<h1>Web Google Maps</h1> <p><img src="./static/description/google_map.gif" alt="google_map"></p> <p>This module contains three new features: - New view type and mode <code>&quot;google_map&quot;</code> - New widget <code>&quot;gplaces_address_autocomplete&quot;</code> - New widget <code>&quot;gplaces_autocomplete&quot;</code></p> <h2>Map view <code>&quot;google_map&quot;</code></h2> <p>Enable you to display <code>res.partner</code> geolocation on map or any model contains geolocation.<br> This feature will work seamlessly with Odoo means you can search your partner location using Odoo search feature. </p> <p>These are available attributes that you can customize - <code>lat</code> : an attritube to tell the map the latitude field <strong>[mandatory]</strong> - <code>lng</code> : an attritute to tell the map the longitude field <strong>[mandatory]</strong> - <code>color</code> : an attribute to modify marker color, any given color will set all markers color <strong>[optional]</strong>. - <code>colors</code> : work like attribute <code>color</code> but more configurable (you can set marker color depends on condition you defined) <strong>[optional]</strong> - <code>library</code> : an attribute to indicates which google map library to load.<br> This options has two values:<br> 1. <code>geometry</code> [default] 2. <s><code>drawing</code></s> - <code>disable_cluster_marker</code>: if you want to disable cluster marker, you can set this attribute to <code>True</code> <strong>[optional]</strong> - <code>gesture_handling</code>: gesture control for the map. Available options: <code>cooperative</code>, <code>greedy</code>, <code>auto(default)</code> <a href="https://developers.google.com/maps/documentation/javascript/interaction#controlling_gesture_handling">source</a> <strong>[optional]</strong></p> <h3>How to create the view?</h3> <p>Example ```xml &lt;!-- View --&gt; <record id="view_res_partner_map" model="ir.ui.view"> <field name="name">view.res.partner.map</field> <field name="model">res.partner</field> <field name="arch" type="xml"> <google_map class="o_res_partner_map" string="Map" lat="partner_latitude" lng="partner_longitude" colors="blue:company_type=='person';green:company_type=='company';" disable_cluster_marker="True" gesture_handling="cooperative"> <field name="id"/> <field name="partner_latitude"/> <field name="partner_longitude"/> <field name="color"/> <field name="display_name"/> <field name="title"/> <field name="email"/> <field name="parent_id"/> <field name="is_company"/> <field name="function"/> <field name="phone"/> <field name="street"/> <field name="street2"/> <field name="zip"/> <field name="city"/> <field name="country_id"/> <field name="mobile"/> <field name="state_id"/> <field name="category_id"/> <field name="image_128"/> <field name="type"/> <field name="company_type"/> <templates> <t t-name="kanban-box"> <div class="oe_kanban_global_click o_kanban_record_has_image_fill o_res_partner_kanban"> <t t-if="!record.is_company.raw_value"> <t t-if="record.type.raw_value === 'delivery'" t-set="placeholder" t-value="'/base/static/img/truck.png'"/> <t t-elif="record.type.raw_value === 'invoice'" t-set="placeholder" t-value="'/base/static/img/money.png'"/> <t t-else="" t-set="placeholder" t-value="'/base/static/img/avatar_grey.png'"/> <div class="o_kanban_image_fill_left d-none d-md-block" t-attf-style="background-image:url('#{kanban_image('res.partner', 'image_128', record.id.raw_value, placeholder)}')"> <img class="o_kanban_image_inner_pic" t-if="record.parent_id.raw_value" t-att-alt="record.parent_id.value" t-att-src="kanban_image('res.partner', 'image_128', record.parent_id.raw_value)"/> </div> <div class="o_kanban_image rounded-circle d-md-none" t-attf-style="background-image:url('#{kanban_image('res.partner', 'image_128', record.id.raw_value, placeholder)}')"> <img class="o_kanban_image_inner_pic" t-if="record.parent_id.raw_value" t-att-alt="record.parent_id.value" t-att-src="kanban_image('res.partner', 'image_128', record.parent_id.raw_value)"/> </div> </t> <t t-elif="record.image_128.raw_value"> <t t-set="placeholder" t-value="'/base/static/img/company_image.png'"/> <div class="o_kanban_image_fill_left o_kanban_image_full" t-attf-style="background-image: url(#{kanban_image('res.partner', 'image_128', record.id.raw_value, placeholder)})" role="img"/> </t> <div class="oe_kanban_details"> <strong class="o_kanban_record_title oe_partner_heading"><field name="display_name"/></strong> <div class="o_kanban_tags_section oe_kanban_partner_categories"/> <ul> <li t-if="record.parent_id.raw_value and !record.function.raw_value"><field name="parent_id"/></li> <li t-if="!record.parent_id.raw_value and record.function.raw_value"><field name="function"/></li> <li t-if="record.parent_id.raw_value and record.function.raw_value"><field name="function"/> at <field name="parent_id"/></li> <li t-if="record.city.raw_value and !record.country_id.raw_value"><field name="city"/></li> <li t-if="!record.city.raw_value and record.country_id.raw_value"><field name="country_id"/></li> <li t-if="record.city.raw_value and record.country_id.raw_value"><field name="city"/>, <field name="country_id"/></li> <li t-if="record.email.raw_value" class="o_text_overflow"><field name="email"/></li> </ul> <div class="oe_kanban_partner_links"/> </div> </div> </t> </templates> </google_map> </field> </record></p> <pre><code>&lt;!-- Action --&gt; &lt;record id=&quot;action_partner_map&quot; model=&quot;ir.actions.act_window&quot;&gt; ... &lt;field name=&quot;view_mode&quot;&gt;kanban,tree,form,google_map&lt;/field&gt; ... &lt;/record&gt; </code></pre> <p>```</p> <p>The view looks familiar?<br> Yes, you&#39;re right.<br> The marker infowindow will use <code>kanban-box</code> kanban card style. </p> <h3>How to setup color for marker on map?</h3> <p>There are two attributes: - <code>colors</code><br> Allow you to display different marker color to represent a record on map - <code>color</code><br> One marker color for all records on map</p> <p>Example: ```xml &lt;!-- colors --&gt; <google_map string="Map" lat="partner_latitude" lng="partner_longitude" colors="green:company_type=='person';blue:company_type=='company';"> ... </google_map></p> <pre><code>&lt;!-- color --&gt; &lt;google_map string=&quot;Map&quot; lat=&quot;partner_latitude&quot; lng=&quot;partner_longitude&quot; color=&quot;orange&quot;&gt; ... &lt;/google_map&gt; </code></pre> <p>```</p> <h2>New widget <code>&quot;gplaces_address_autocomplete&quot;</code></h2> <p>New widget to integrate <a href="https://developers.google.com/maps/documentation/javascript/examples/places-autocomplete-addressform">Place Autocomplete Address Form</a>.<br> ### Widget options:</p> <ol> <li><p>Google componennt <code>component_form</code><br> Is an option used to modify which value you want to take from an objects returned by the geocoder.<br> Full documentation about Google component types can be found <a href="https://developers.google.com/maps/documentation/geocoding/intro#Types">here</a> By default this option are configured like the following value <code>javascript { street_number: &#39;long_name&#39;, route: &#39;long_name&#39;, intersection: &#39;short_name&#39;, political: &#39;short_name&#39;, country: &#39;short_name&#39;, administrative_area_level_1: &#39;short_name&#39;, administrative_area_level_2: &#39;short_name&#39;, administrative_area_level_3: &#39;short_name&#39;, administrative_area_level_4: &#39;short_name&#39;, administrative_area_level_5: &#39;short_name&#39;, colloquial_area: &#39;short_name&#39;, locality: &#39;short_name&#39;, ward: &#39;short_name&#39;, sublocality_level_1: &#39;short_name&#39;, sublocality_level_2: &#39;short_name&#39;, sublocality_level_3: &#39;short_name&#39;, sublocality_level_5: &#39;short_name&#39;, neighborhood: &#39;short_name&#39;, premise: &#39;short_name&#39;, postal_code: &#39;short_name&#39;, natural_feature: &#39;short_name&#39;, airport: &#39;short_name&#39;, park: &#39;short_name&#39;, point_of_interest: &#39;long_name&#39;, floor: &#39;short_name&#39;, establishment: &#39;short_name&#39;, point_of_interest: &#39;short_name&#39;, parking: &#39;short_name&#39;, post_box: &#39;short_name&#39;, postal_town: &#39;short_name&#39;, room: &#39;short_name&#39;, bus_station: &#39;short_name&#39;, train_station: &#39;short_name&#39;, transit_station: &#39;short_name&#39;, } </code> This configuration can be modify into view field definition.<br> Example: <code>xml &lt;record id=&quot;view_res_partner_form&quot; model=&quot;ir.ui.view&quot;&gt; ... &lt;field name=&quot;arch&quot; type=&quot;xml&quot;&gt; ... &lt;field name=&quot;street&quot; widget=&quot;gplaces_address_form&quot; options=&quot;{&#39;component_form&#39;: {&#39;street_number&#39;: &#39;short_name&#39;}}&quot;/&gt; ... &lt;/field&gt; &lt;/record&gt; </code></p></li> <li><p>Odoo fields mapping <code>fillfields</code><br> Is an option that will be influenced by <code>gplaces_address_autocomplete</code> widget.<br> This options should contains known <code>fields</code> that you want the widget to fulfill a value for each given field automatically.<br> A field can contains one or multiple elements of component form<br> By default this options are configured like the following <code>javascript { &#39;street&#39;: [&#39;street_number&#39;, &#39;route&#39;], &#39;street2&#39;: [&#39;administrative_area_level_3&#39;, &#39;administrative_area_level_4&#39;, &#39;administrative_area_level_5&#39;], &#39;city&#39;: [&#39;locality&#39;, &#39;administrative_area_level_2&#39;], &#39;zip&#39;: &#39;postal_code&#39;, &#39;state_id&#39;: &#39;administrative_area_level_1&#39;, &#39;country_id&#39;: &#39;country&#39;, } </code></p></li> </ol> <p>This configuration can be modify into view field definition as well<br> Example: <code>xml &lt;record id=&quot;view_res_partner_form&quot; model=&quot;ir.ui.view&quot;&gt; ... &lt;field name=&quot;arch&quot; type=&quot;xml&quot;&gt; ... &lt;field name=&quot;street&quot; widget=&quot;google_places&quot; options=&quot;{&#39;fillfields&#39;: {&#39;street2&#39;: [&#39;route&#39;, &#39;street_number&#39;]}}&quot;/&gt; ... &lt;/field&gt; &lt;/record&gt; </code> </p> <ol> <li><p>Geolocation fields latitude <code>lat</code> and longitude <code>lng</code><br> This options tell the widget the fields geolocation, in order to have this fields filled automatically.</p></li> <li><p>Address mode <code>mode</code><br> Is an option that will be used to define the mode of the widget. Either by populate the Google address into Odoo fields or just simply take the Google address into your Char field.<br> Available values are <code>&#39;address_format&#39;</code> and <code>&#39;no_address_format&#39;</code>.<br> Example: <code>xml &lt;field name=&quot;address&quot; widget=&quot;gplaces_address_autocomplete&quot; options=&quot;{ &#39;mode&#39;: &#39;no_address_format&#39;, &#39;lat&#39;: &#39;latitude&#39;, &#39;lng&#39;: &#39;longitude&#39;, &#39;display_name&#39;: &#39;formatted_address&#39;, &#39;types&#39;: []}&quot; /&gt; </code> It&#39;s recommended to also defined geolocation fields (latitude and longitude) so that you see can the address on map. </p> <ol> <li>Place autocomplete requests <a href="https://developers.google.com/maps/documentation/places/web-service/supported_types#table3"><code>types</code></a></li> </ol></li> </ol> <h2>New widget <code>&quot;gplaces_autocomplete&quot;</code></h2> <p>New widget to integrate <a href="https://developers.google.com/maps/documentation/javascript/examples/places-autocomplete">Place Autocomplete</a> in Odoo.</p> <h3>Widget options:</h3> <p>This widget have similar configuration to <code>gplaces_address_autocomplete</code> except for <code>mode</code> option.</p> <ol> <li>Fill fields <code>fillfields</code><br> This configuration works similar to <code>gplaces_address_autocomplete</code>. By default this options are configured like following value: <code>javascript { general: { name: &#39;name&#39;, website: &#39;website&#39;, phone: [&#39;international_phone_number&#39;, &#39;formatted_phone_number&#39;] }, geolocation: { partner_latitude: &#39;latitude&#39;, partner_longitude: &#39;longitude&#39; }, address: { street: [&#39;street_number&#39;, &#39;route&#39;], street2: [&#39;administrative_area_level_3&#39;, &#39;administrative_area_level_4&#39;, &#39;administrative_area_level_5&#39;], city: [&#39;locality&#39;, &#39;administrative_area_level_2&#39;], zip: &#39;postal_code&#39;, state_id: &#39;administrative_area_level_1&#39;, country_id: &#39;country&#39; } }; </code> ## Technical This module will install <code>base_setup</code> and <code>base_geolocalize</code>.<br> <em>I recommend you to setup <strong>Google Maps Key API</strong> and add it into Odoo <code>Settings &gt; General</code> Settings when you installed this module</em></li> </ol> <p><em><strong>List of Google APIs &amp; services required in order to make all features works</strong></em> - Geocoding API - Maps JavaScript API - Places API</p> <p>Visit this <a href="https://developers.google.com/maps/documentation/javascript/get-api-key">page</a> of how to get Google API Key</p> <p>If you discover a bug, please create an issue.<br> If you want to contribute, please fork the repository and create a pull request.</p>