Tecnativa / doodba

Base image for making the creation of customized Odoo environments a piece of cake
Apache License 2.0
423 stars 302 forks source link

[17.0] Geoip not working correctly #600

Closed shaneo1 closed 6 months ago

shaneo1 commented 6 months ago

I have installed Odoo 17 using Doodba and use global price lists and have used this in odoo 16 with the geolite2 database. But was only able to get it working using a thirdparty app from odoo.com.

I have installed odoo 17 using a different docker-compose script that puts both Geolite2-city and country in to /usr/share/GeoIP as instructed my the odoo documentation.

Now in Doodba there is on the city database and the odoo.conf in pointing to its location geoip_database = /opt/odoo/auto/geoip/GeoLite2-City.mmdb. and the geoip does not work for the country, I believe this is a bug in the scripting as I am unable to detect the customer country against the IP address. How can I rectify this issue.

ap-wtioit commented 6 months ago

@shaneo1 did you setup the geoip credentials correctly? (is there a database in /opt/odoo/auto/geoip/GeoLite2-City.mmdb?)

shaneo1 commented 6 months ago

There is a city database yes.

On Mon, 4 Mar 2024, 06:31 Andreas Perhab, @.***> wrote:

@shaneo1 https://github.com/shaneo1 did you setup the geoip credentials correctly? (is there a database in /opt/odoo/auto/geoip/GeoLite2-City.mmdb?)

— Reply to this email directly, view it on GitHub https://github.com/Tecnativa/doodba/issues/600#issuecomment-1975826905, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABCKK4VWJXSCQPJSNZBIZALYWQINLAVCNFSM6AAAAABEDGZ4RGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSNZVHAZDMOJQGU . You are receiving this because you were mentioned.Message ID: @.***>

ap-wtioit commented 6 months ago

Ok just investigated (because we have an issue with the new download limits for GeoIP and testing on our CI) and i can confirm the parameters for GeoIP in Odoo have changed in Odoo 17.0 and are no longer compatible with the doodba implementation:

Odoo 17.0

        group.add_option("--geoip-city-db", "--geoip-db", dest="geoip_city_db", my_default='/usr/share/GeoIP/GeoLite2-City.mmdb',
                         help="Absolute path to the GeoIP City database file.")
        group.add_option("--geoip-country-db", dest="geoip_country_db", my_default='/usr/share/GeoIP/GeoLite2-Country.mmdb',
                         help="Absolute path to the GeoIP Country database file.")

Odoo 16.0 and before

         group.add_option("--geoip-db", dest="geoip_database", my_default='/usr/share/GeoIP/GeoLite2-City.mmdb',
                         help="Absolute path to the GeoIP database file.")

As a workaround you should be able to add the following file to your odoo/custom/conf.d directory: 994_geoip.conf

[options]
geoip_city_db = /opt/odoo/auto/geoip/GeoLite2-City.mmdb

@shaneo1 could you update the issue title with a prefix [17.0] to make it clear to everyone that this is for 17.0

shaneo1 commented 6 months ago

Ok just investigated (because we have an issue with the new download limits for GeoIP and testing on our CI) and i can confirm the parameters for GeoIP in Odoo have changed in Odoo 17.0 and are no longer compatible with the doodba implementation:

Odoo 17.0

        group.add_option("--geoip-city-db", "--geoip-db", dest="geoip_city_db", my_default='/usr/share/GeoIP/GeoLite2-City.mmdb',
                         help="Absolute path to the GeoIP City database file.")
        group.add_option("--geoip-country-db", dest="geoip_country_db", my_default='/usr/share/GeoIP/GeoLite2-Country.mmdb',
                         help="Absolute path to the GeoIP Country database file.")

Odoo 16.0 and before

         group.add_option("--geoip-db", dest="geoip_database", my_default='/usr/share/GeoIP/GeoLite2-City.mmdb',
                         help="Absolute path to the GeoIP database file.")

As a workaround you should be able to add the following file to your odoo/custom/conf.d directory: 994_geoip.conf

[options]
geoip_city_db = /opt/odoo/auto/geoip/GeoLite2-City.mmdb

@shaneo1 could you update the issue title with a prefix [17.0] to make it clear to everyone that this is for 17.0

Thank you for you reply I didn't think I was going crazy when I submitted the issue. As for the file 994_geoip.conf where can I find this?

ap-wtioit commented 6 months ago

The file should be a text file with the contents above and should be placed inside the odoo/custom/conf.d directory of your doodba project. You can have a look at the tests for custom settings in the settings test. All files in the conf.d directory should be merged together into /opt/odoo/auto/odoo.conf in the container.

shaneo1 commented 6 months ago

Ok now have this working in Odoo 17 here are the changes I made the project to get GeoLite2 to place nicely.

volumes:
  - ./odoo/GeoLite2:/usr/share/GeoIP:rw
  - ./odoo/custom/conf.d/geoip.conf:/etc/odoo/odoo.conf.d/geoip.conf:ro
command:
  - --geoip-city-db=/usr/share/GeoIP/GeoLite2-City.mmdb
  - --geoip-country-db=/usr/share/GeoIP/GeoLite2-Country.mmdb
  - --config=/etc/odoo/odoo.conf.d/geoip.conf

The folder /odoo/GeoLite2 was added and both GeoLite2-City.mmdb and GeoLite2-Country.mmdb uploaded from Maxmind website. In addition I created a geoip.conf file in /odoo/custom/conf.d

[options]
geoip_database = /usr/share/GeoIP/GeoLite2-City.mmdb

Then run docker-compose up -d

Everything is now working as it should be. This allows for City and Country

pedrobaeza commented 6 months ago

Fixed in #603

shaneo1 commented 6 months ago

Awesome news this will help a lot of people out. Great work everyone

On Thu, 7 Mar 2024 at 18:15, Pedro M. Baeza @.***> wrote:

Fixed in #603 https://github.com/Tecnativa/doodba/pull/603

— Reply to this email directly, view it on GitHub https://github.com/Tecnativa/doodba/issues/600#issuecomment-1984153731, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABCKK4QXHQSREMUHAHW2QUDYXCVELAVCNFSM6AAAAABEDGZ4RGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSOBUGE2TGNZTGE . You are receiving this because you were mentioned.Message ID: @.***>