gityopie / odoo-addons

Odoo and Google maps integration
GNU Lesser General Public License v3.0
100 stars 160 forks source link

Awesome #5

Closed gdgellatly closed 7 years ago

gdgellatly commented 7 years ago

Hi @gityopie ,

The web_google_maps module is really good. My country has slightly weird addressing so Google maps returns fields differently so had to make some changes, but I will follow your work closely. Equally, you can always check any changes I make and integrate freely as you wish.

https://github.com/odoonz/misc-gityopie

Its still very much WIP, but there might be something useful, although I am useless at Javascript.

gityopie commented 7 years ago

Hi @gdgellatly

Thank you.

I've check your modification (it's little bit complex). Actually, you can modify the fields components via view (the xml) without touch the JS code. but after check your modification, you want big changes :)

I just pushed a new branch(v1020170801), check the diff (https://github.com/gityopie/odoo-addons/commit/a576b5b051febee810660c2e3abaec92e3a080ee) The changes are as follows:

  1. Define a new function gmaps_populate_address, this new function will be use to populate the values returns by places autocomplete(use in the maps) and places autocomplete address form(use in google_places widget). The idea is to have one dedicated function use to populate the values returned by Google(places autocomplete).
  2. Define a delimiter(this value can be modify via fields options). This delimiter use to join an Array. Example, on fillfields options for google_places widget, it can be set up with string (single component form) or an Array (multiple component form).
    Sample screenshot after applied the update screen shot 2017-08-01 at 9 55 39 pm As you can see, no more comma to separate between street_number and route :) yeay, it's an address in New Zealand :))

My suggestions, You can update the fields component forms (put any google component forms you need into each fields) or play with it until you found the best options that match your address format.

<field name="street" widget="google_places" options="{'fillfields': {'street2': ['street_number']}}"/>

I believe all of them or at least one of the component forms is not existed by the time you selected an address from the dropdown.

or if you want an easy way to debug the values returned by Google go visit this page(https://developers.google.com/maps/documentation/javascript/examples/places-autocomplete-addressform) you can open the code sample in JSFiddle and debug it

Hope this helpful. good luck :)

gdgellatly commented 7 years ago

Hi @gityopie,

I tried that branch, it doesn't quite work as I need but is really close. Probably close enough that I can use. In any case, I will probably change my changes into an extension of your work rather than an overwrite.

I've found a few small issues with the map view.

(you can check with web_google_maps_sale a little test module I made at https://github.com/odoonz/misc-gityopie)

Also looking at map_view.js I think it might be possible for routes rather than having just an origin and destination, is to have a context key like {'paths': [(name, lat_lng),(name2, lat_lng2),(...)]}.

The use case I am thinking of here is adding and sequencing some deliveries onto a picking wave and displaying the route to all destinations. (Then as they are delivered updating the estimated time of arrival for the remaining ones)

The create partner from map is OK, but I think what would be awesome is being able to drag the marker to a place then create. Also the name ends up as the name of the road and you need to go and find it and edit it.

Anyway this is just feedback, if these are things you want to do go for it, if you have some feedback on how to do, I'm more than happy to try and do myself and make PR back.

gityopie commented 7 years ago

Hi @gdgellatly,

The reason to have only two letters on the marker is keep it simple as possible (imagine if you have long string of name). About some of fields type doesn't show up properly on marker info window, yeah you're right. Until now, it's only works for string and M2O fields (like country_id and state_id). For me, the information that will be shown on info window of marker should be a short info (you know you're not going to put everything on it) -> I will consider to add a link for switch view, to form view for example.

About the possibility to modify the name and drag-and-drop feature when create new partner from map. Yep, that's great. Actually, I already have that idea when working on that feature. I'll try working on it and will include it on next update.

And the last, about the possibility to have different options(path) for route, yeah that's a great idea too. I haven't check that far, but I will put it my todo list. it would be great if you can make it :)

Thanks a lot for your feedback.

gdgellatly commented 7 years ago

Hi @gityopie

I have experimental support for waypoints running. Was pretty easy in the end to get it going. Still needs a lot of work and an actual working use case module. I just hardcoded some directions to get started. Will work on it when I've written the module for which this is the usecase in the next week but the current work (with hardcoded NZ inputs) is here.

https://github.com/odoonz/misc-gityopie/tree/waypoints

btw - all my testing so far has been on enterprise and all working good.