Skip to content

Conversation

@anusriNPS
Copy link

@anusriNPS anusriNPS commented Aug 7, 2025

Added edit button in popup of record shown in geoengine view which allows user to edit records by opening new tab in browser window.

@anusriNPS anusriNPS marked this pull request as draft August 7, 2025 06:34
Copy link

@cparadis-impressfoods cparadis-impressfoods left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@anusriNPS anusriNPS force-pushed the 16.0-enhance-geoengine branch from 3df97af to fd809d6 Compare September 3, 2025 12:27
@anusriNPS anusriNPS marked this pull request as ready for review September 3, 2025 12:28
@anusriNPS anusriNPS force-pushed the 16.0-enhance-geoengine branch from fd809d6 to fae81fc Compare September 3, 2025 12:37
Comment on lines 17 to 21
<div
t-if="isGeoengineAdmin"
id="popup-editor"
class="ol-popup-editor text-primary"
t-on-click="onEditButtonClicked"
/>

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have some observations about this:

  • Is really GeoenginAdmin check needed? I think is more correct that the check should be done on the work order itself (user could be GeoengineAdmin but not allowed to edit a specific WO, how is this situation managed?);
  • When moving the cursor over the button, it doesn't give me the impression that it's clickable. Please could you improve this by adding a clickable attribute or changing the div into a button or something similar?
  • When clicking on edit button, the form view just opened is "full screen", hiding the upper navigation bar, and when going back, map view is reset;
  • suggestion: clicking the "open" button, i see the same form that I have by clicking on "edit" button. What if the open button opens form view in edit mode (depending of access rules of course)? In that case, "edit" button would become obsolete, but the interface should become more clear;

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re: the first point, this is a generic geoengine module, it could be used with any object, not just fieldservice. But in general, I agree with checking permissions on the object itself if possible and not requiring admin rights on the Geoengine app.

If it's too complicated, Odoo probably already checks permissions in other ways so I'd rather leave both buttons for everyone, at least as a first implementation.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. Regarding edit button, icon is shown as clickable attribute when hovered around it. Edit button opens url in new tab with navigation bar and also restores history in geoengine view.
  2. Regarding permission on object level:
    a. Tried to hide the editbutton using ormservice and reading permission for record from backend during onwillstart() in geoengineRenderer. However, each record related information is attached in geoengineRenderer only when displayPopupRecord() method is called and geoenginerecord is mounted based on information passed from recordPanel template. Component is getting destroyed while trying to fetch specific record from geoengineRenderer setup. So, could not hide the button completely. This would be best option for this case but could not achieved.
    b. Currently, if a model has a field named "can_write", if passed in info_box template from geoengine view definition, record is validated based on can_write field and allows user to edit the record. If not, user is notified that sufficient permissions are not available to edit the record. If info_box template does not have "can_write" field, all users is allowed to edit the record.(default behaviour).

Note: Without approach "b", by default even when user is allowed to edit the record, permissions are validated in backend and user is blocked in case the user does not have sufficient permissions.

IMO, I would like to stick not using approach "b" as already backend permissions are validated even without exposing new field in model for this purpose which seems to be overhead.

Please let me know your views.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes on the edit button now are ok.
About permissions, since now the form opens in a new tab, is ok for me to remove new checks added in this PR and stay with the "default" ones when opening the new tab.

Copy link
Author

@anusriNPS anusriNPS Sep 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed checking permission based on "can_write" field introduced from model and preserved default behaviour for permission check of geoengine views for edit button.

@anusriNPS anusriNPS force-pushed the 16.0-enhance-geoengine branch 2 times, most recently from 67c79d9 to 801c2f6 Compare September 24, 2025 10:02
@OCA-git-bot
Copy link
Contributor

This PR has the approved label and has been created more than 5 days ago. It should therefore be ready to merge by a maintainer (or a PSC member if the concerned addon has no declared maintainer). 🤖

Copy link
Contributor

@HekkiMelody HekkiMelody left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small code cleanup suggestion, otherwise seems ok.

Comment on lines 74 to 89
var web_base_url = window.origin;
var web_url = window.location.href;
var searchParams = new URLSearchParams(web_url.split("#")[1]);
var action_url =
web_base_url +
"/web#id=" +
String(resId) +
"&view_type=form&model=" +
resModel +
"&menu_id=" +
searchParams.get("menu_id");
this.actionService.doAction({
type: "ir.actions.act_url",
target: "_blank",
url: action_url,
});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

chore: not at all a fan of building the URL manually, but if there's no other easy way to do it, that's fine.

I would suggest building the action_url in a less "manual" way, like in this module https://github.com/OCA/web/blob/16.0/web_widget_open_tab/static/src/js/open_tab_widget.esm.js#L12-L25

Also, please use const and let instead of var.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated as suggested

   Added edit button in popup of record shown in geoengine
view which allows user to edit values of record from
geoengine view.
@anusriNPS anusriNPS force-pushed the 16.0-enhance-geoengine branch from 801c2f6 to 6eeb3f9 Compare September 26, 2025 06:41
Copy link
Contributor

@HekkiMelody HekkiMelody left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code review, LGTM

@github-actions
Copy link

There hasn't been any activity on this pull request in the past 4 months, so it has been marked as stale and it will be closed automatically if no further activity occurs in the next 30 days.
If you want this PR to never become stale, please ask a PSC member to apply the "no stale" label.

@github-actions github-actions bot added the stale PR/Issue without recent activity, it'll be soon closed automatically. label Jan 25, 2026
@HekkiMelody
Copy link
Contributor

@OCA/geospatial-maintainers We've been using this successfully for a few months now. I would be grateful if you could review this. Thanks

@legalsylvain
Copy link
Contributor

No review, but as it is validated by 3 people. merging.

/ocabot merge minor

thanks for your contribution.

@OCA-git-bot
Copy link
Contributor

This PR looks fantastic, let's merge it!
Prepared branch 16.0-ocabot-merge-pr-409-by-legalsylvain-bump-minor, awaiting test results.

OCA-git-bot added a commit that referenced this pull request Jan 26, 2026
Signed-off-by legalsylvain
@OCA-git-bot
Copy link
Contributor

@legalsylvain your merge command was aborted due to failed check(s), which you can inspect on this commit of 16.0-ocabot-merge-pr-409-by-legalsylvain-bump-minor.

After fixing the problem, you can re-issue a merge command. Please refrain from merging manually as it will most probably make the target branch red.

@HekkiMelody
Copy link
Contributor

I see that the error is due to

2026-01-26 11:26:30,614 334 INFO odoo odoo.addons.base_geolocalize.models.base_geocoder: openstreetmap nominatim service called 
2026-01-26 11:26:30,615 334 WARNING odoo odoo.addons.base_geolocalize.models.base_geocoder: Request to openstreetmap failed.
Code: 403
Content: b'<html>\n<head>\n<title>Access blocked</title>\n</head>\n<body>\n<h1>Access blocked</h1>\n\n<p>You have been blocked because you have violated the\n<a href="https://operations.osmfoundation.org/policies/nominatim/">usage policy</a>\nof OSM\'s Nominatim geocoding service. Please be aware that OSM\'s resources are\nlimited and shared between many users. The usage policy is there to ensure that\nthe service remains usable for everybody.</p>\n\n<p>Please review the terms and make sure that your\nsoftware adheres to the terms. You should in particular verify that you have set a\n<b>custom HTTP referrer or HTTP user agent</b> that identifies your application, and\nthat you are not overusing the service with massive bulk requests.\nIf you do that then the block usually goes away after some hours of inactivity.</p>\n\n<p>Please be aware that we are providing this service as-is and without any\nguarantees. We cannot provide support. If you need that, please have a look\nat comercial alternatives (also listed on the usage policy page) or set up\nyour own instance of Nominatim.</p>\n</body>\n</head>\n' 
2026-01-26 11:26:30,617 334 INFO odoo odoo.addons.geoengine_base_geolocalize.tests.test_geoengine_partner: ====================================================================== 
2026-01-26 11:26:30,617 334 ERROR odoo odoo.addons.geoengine_base_geolocalize.tests.test_geoengine_partner: ERROR: TestGeoenginePartner.test_geo_localize
Traceback (most recent call last):
  File "/opt/odoo/addons/base_geolocalize/models/base_geocoder.py", line 95, in _call_openstreetmap
    result = response.json()
  File "/opt/odoo-venv/lib/python3.10/site-packages/requests/models.py", line 900, in json
    return complexjson.loads(self.text, **kwargs)
  File "/opt/odoo-venv/lib/python3.10/site-packages/simplejson/__init__.py", line 514, in loads
    return _default_decoder.decode(s)
  File "/opt/odoo-venv/lib/python3.10/site-packages/simplejson/decoder.py", line 386, in decode
    obj, end = self.raw_decode(s)
  File "/opt/odoo-venv/lib/python3.10/site-packages/simplejson/decoder.py", line 416, in raw_decode
    return self.scan_once(s, idx=_w(s, idx).end())
simplejson.errors.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

we may be hitting openstreetmaps a bit too often? We may have to refactor the tests to not call OSM, or skip some tests in case of Access Denied

@anusriNPS
Copy link
Author

I see that the error is due to

2026-01-26 11:26:30,614 334 INFO odoo odoo.addons.base_geolocalize.models.base_geocoder: openstreetmap nominatim service called 
2026-01-26 11:26:30,615 334 WARNING odoo odoo.addons.base_geolocalize.models.base_geocoder: Request to openstreetmap failed.
Code: 403
Content: b'<html>\n<head>\n<title>Access blocked</title>\n</head>\n<body>\n<h1>Access blocked</h1>\n\n<p>You have been blocked because you have violated the\n<a href="https://operations.osmfoundation.org/policies/nominatim/">usage policy</a>\nof OSM\'s Nominatim geocoding service. Please be aware that OSM\'s resources are\nlimited and shared between many users. The usage policy is there to ensure that\nthe service remains usable for everybody.</p>\n\n<p>Please review the terms and make sure that your\nsoftware adheres to the terms. You should in particular verify that you have set a\n<b>custom HTTP referrer or HTTP user agent</b> that identifies your application, and\nthat you are not overusing the service with massive bulk requests.\nIf you do that then the block usually goes away after some hours of inactivity.</p>\n\n<p>Please be aware that we are providing this service as-is and without any\nguarantees. We cannot provide support. If you need that, please have a look\nat comercial alternatives (also listed on the usage policy page) or set up\nyour own instance of Nominatim.</p>\n</body>\n</head>\n' 
2026-01-26 11:26:30,617 334 INFO odoo odoo.addons.geoengine_base_geolocalize.tests.test_geoengine_partner: ====================================================================== 
2026-01-26 11:26:30,617 334 ERROR odoo odoo.addons.geoengine_base_geolocalize.tests.test_geoengine_partner: ERROR: TestGeoenginePartner.test_geo_localize
Traceback (most recent call last):
  File "/opt/odoo/addons/base_geolocalize/models/base_geocoder.py", line 95, in _call_openstreetmap
    result = response.json()
  File "/opt/odoo-venv/lib/python3.10/site-packages/requests/models.py", line 900, in json
    return complexjson.loads(self.text, **kwargs)
  File "/opt/odoo-venv/lib/python3.10/site-packages/simplejson/__init__.py", line 514, in loads
    return _default_decoder.decode(s)
  File "/opt/odoo-venv/lib/python3.10/site-packages/simplejson/decoder.py", line 386, in decode
    obj, end = self.raw_decode(s)
  File "/opt/odoo-venv/lib/python3.10/site-packages/simplejson/decoder.py", line 416, in raw_decode
    return self.scan_once(s, idx=_w(s, idx).end())
simplejson.errors.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

we may be hitting openstreetmaps a bit too often? We may have to refactor the tests to not call OSM, or skip some tests in case of Access Denied

Will check on the issue

@anusriNPS anusriNPS force-pushed the 16.0-enhance-geoengine branch from f0b0368 to 6fc3314 Compare January 27, 2026 10:28
…tMap

   Avoiding direct call to openstreetmap which results in
Access denied (403) due to resource usage limits and hence mocking data
for openstreetmap url as part of geoengine partner testcases.
@anusriNPS anusriNPS force-pushed the 16.0-enhance-geoengine branch from 6fc3314 to d125f93 Compare January 27, 2026 10:38
Copy link

@quirino95 quirino95 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Thank you for the fix!

Copy link
Contributor

@HekkiMelody HekkiMelody left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code review, LGTM for the test mock too.

Thank you!

@HekkiMelody
Copy link
Contributor

@OCA/geospatial-maintainers we've fixed the issue with the flaky tests (even though they were out of scope for this PR) could you try the merge again? Thank you

We can forward port both changes to the newest versions too

@legalsylvain
Copy link
Contributor

thanks for the contribution !

/ocabot merge minor

@OCA-git-bot
Copy link
Contributor

This PR looks fantastic, let's merge it!
Prepared branch 16.0-ocabot-merge-pr-409-by-legalsylvain-bump-minor, awaiting test results.

@OCA-git-bot OCA-git-bot merged commit 738ca62 into OCA:16.0 Jan 27, 2026
7 checks passed
@OCA-git-bot
Copy link
Contributor

Congratulations, your PR was merged at ba5121e. Thanks a lot for contributing to OCA. ❤️

@HekkiMelody HekkiMelody deleted the 16.0-enhance-geoengine branch January 27, 2026 12:02
@HekkiMelody
Copy link
Contributor

Thank you @legalsylvain !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved merged 🎉 ready to merge stale PR/Issue without recent activity, it'll be soon closed automatically.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants