gityopie / odoo-addons

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

[12.0] Server error #140

Closed FedericoLaTorre closed 4 years ago

FedericoLaTorre commented 4 years ago

I have this server error when I click map icon (I replace my domain with "mydomain")

Error: Uncaught TypeError: Cannot read property 'equals' of undefined

https://mydomain/web/content/11447-8f5a76c/web.assets_backend.js:3767 Rastreo de error: TypeError: Cannot read property 'equals' of undefined at https://mydomain/web/content/11447-8f5a76c/web.assets_backend.js:3767:244 at Array.forEach () at Class._clusterAddMarker (https://mydomain/web/content/11447-8f5a76c/web.assets_backend.js:3767:194) at Class._createMarker [as _super] (https://mydomain/web/content/11447-8f5a76c/web.assets_backend.js:3766:75) at Class._createMarker (https://mydomain/web/content/11447-8f5a76c/web.assets_backend.js:3847:722) at Class._createMarker (https://mydomain/web/content/11439-d372d28/web.assets_common.js:3541:371) at https://mydomain/web/content/11447-8f5a76c/web.assets_backend.js:3769:1934 at Function. (https://mydomain/web/content/11439-d372d28/web.assets_common.js:12:558) at Class._renderUngrouped (https://mydomain/web/content/11447-8f5a76c/web.assets_backend.js:3769:1761) at Class._renderMarkers (https://mydomain/web/content/11447-8f5a76c/web.assets_backend.js:3769:941)

gityopie commented 4 years ago

Hi @FedericoLaTorre

Thanks for reporting this issue. Unfortunately I couldn't reproduce it on my side Would be great if you can provide details of how to reproduce it. Thank you

FedericoLaTorre commented 4 years ago

Hi, I installed all the modules (it's a production DB) wich has many modules already install, such as web_responsive from OCA and Openworx material backend, and many more OCA Web modules. But it would be great if it works.

gityopie commented 4 years ago

@FedericoLaTorre I'm not able to debug and fix the issue without knowing the problem, my guesses is invalid value of geolocation fields. Are you able to modify the code on your side? If yes, please edit the code on file web_google_maps/static/src/js/view/map/map_renderer.js, change the code start from this line https://github.com/gityopie/odoo-addons/blob/12.0/web_google_maps/static/src/js/view/map/map_renderer.js#L316 with these one

var position;
markerInClusters.forEach(function (_cMarker) {
    position = marker.getPosition();
    if (position && position.equals(_cMarker.getPosition())) {
        existingRecords.push(_cMarker._odooRecord);
    }
});
FedericoLaTorre commented 4 years ago

Hi, I modified like this

/**
         * Handle Multiple Markers present at the same coordinates
         */
        _clusterAddMarker: function (marker) {
            var markerInClusters = this.markerCluster.getMarkers();
            var existingRecords = [];
            if (markerInClusters.length > 0) {
                var position;
                markerInClusters.forEach(function (_cMarker) {
                    position = marker.getPosition();
                    if (position && position.equals(_cMarker.getPosition())) {
                        existingRecords.push(_cMarker._odooRecord);
                    }
                });
            }
            this.markerCluster.addMarker(marker);
            google.maps.event.addListener(
                marker,
                'click',
                this._markerInfoWindow.bind(this, marker, existingRecords)
            );
        },
        /**

And all the views dissapear from odoo. Am I modifyng right? Thanks for all the help! I'm new to odoo.

gityopie commented 4 years ago

@FedericoLaTorre yes, it looks correct. What do you mean by "And all the views dissapear from odoo" ?

FedericoLaTorre commented 4 years ago

I mean that appart from the lateral menu of the theme, nothing else appear on screen, no list view, menus, nothing. And also no way to uninstall the module since there is no way to enter the apps menu. I need to rename "map_renderer.js" so I can get the normal behavior again. Also there where no errors on the server log.

gityopie commented 4 years ago

Have you try to debug it? if you are using Chrome browser, right click on any area on Odoo page and then choose Inspector press Ctrl + Shift + I and then go to tab Console After that, reload the page. I guess, there should be an error message or something informative there

Regarding the code modification, could you please double check if you put a comma before and after the method?

...
},
/**
* Handle Multiple Markers present at the same coordinates
*/
_clusterAddMarker: function (marker) {
    var markerInClusters = this.markerCluster.getMarkers();
    var existingRecords = [];
    if (markerInClusters.length > 0) {
        var position;
        markerInClusters.forEach(function (_cMarker) {
            position = marker.getPosition();
            if (position && position.equals(_cMarker.getPosition())) {
                existingRecords.push(_cMarker._odooRecord);
            }
        });
    }
    this.markerCluster.addMarker(marker);
    google.maps.event.addListener(
        marker,
        'click',
        this._markerInfoWindow.bind(this, marker, existingRecords)
    );
},
...
FedericoLaTorre commented 4 years ago

Well, without map_renderer.js it's not giving any errors and map is showing, it was a wrong api key. (thanks for the console tip). If map_renderer.js is present, odoo interface won't load but console is not giving errors, some warnings about missing dependencies.

FedericoLaTorre commented 4 years ago

I also check for the commas and they are present.

gityopie commented 4 years ago

Well, without map_renderer.js it's not giving any errors and map is showing, it was a wrong api key. (thanks for the console tip). If map_renderer.js is present, odoo interface won't load but console is not giving errors, some warnings about missing dependencies.

Strange.. I'm not sure how did you setup the module, without map_renderer.js the module will caused an error and the Google map view will not working.

FedericoLaTorre commented 4 years ago

I first installed it, and then I remove the file. The chrome console shows that the file is missing, but it's working and so is the Odoo interface...

gityopie commented 4 years ago

It's really strange.. :thinking:

gityopie commented 4 years ago

Hi @FedericoLaTorre

Please check the latest version of branch 12.0, the fixes has been applied there I'll closed this one, if you still have an issue feel free to open a new one

Thank you