Skip to content

Conversation

@BernatObrador
Copy link
Contributor

This module adds the zip_id field to the fsm.location form, enabling automatic address completion based on the ZIP code entered in the location’s completion field.

To use the module, follow these steps:

  1. Go to Contacts → Configuration → ZIPs.

  2. Create a new ZIP entry.

  3. Navigate to Field Service → Master Data → Locations.

Select an existing location or create a new one.

In the address section, you’ll now see the ZIP code autocomplete field.
Simply enter the ZIP code, and the system will automatically fill in all related address fields.

cc https://github.com/APSL 7083

@miquelalzanillas @lbarry-apsl @mpascuall @peluko00 @javierobcn @ppyczko please review

@BernatObrador BernatObrador force-pushed the 17.0-add-fieldservice_address_autocomplete branch 2 times, most recently from ce93cdf to c3f5bf8 Compare April 3, 2025 12:32
Copy link
Contributor

@ppyczko ppyczko left a comment

Choose a reason for hiding this comment

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

LGTM, code review and tested in runboat!

Copy link
Contributor

@peluko00 peluko00 left a comment

Choose a reason for hiding this comment

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

LGTM, code review and tested in runboat

Copy link
Member

@lbarry-apsl lbarry-apsl left a comment

Choose a reason for hiding this comment

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

Code and runboat reviewed, LGTM!

Copy link

@mpascuall mpascuall left a comment

Choose a reason for hiding this comment

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

LGTM!

@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). 🤖

@BernatObrador BernatObrador force-pushed the 17.0-add-fieldservice_address_autocomplete branch 2 times, most recently from 82c8525 to 9a2c51b Compare June 6, 2025 11:36
Copy link
Contributor

@ivantodorovich ivantodorovich left a comment

Choose a reason for hiding this comment

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

IMO this module should be named fieldservice_base_location or fieldservice_partner_location, and be auto-installed when base_location is installed

class FsmLocation(models.Model):
_inherit = "fsm.location"

def write(self, vals):
Copy link
Contributor

Choose a reason for hiding this comment

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

You don't need a write override, since fsm.location inherits from res.partner the city_id, state_id, country_id etc are already computed whenever zip_id changes..

I think the only thing this module needs to do is to add the field to the view, similarly to how base_location is doing for the partner: https://github.com/OCA/partner-contact/blob/17.0/base_location/views/res_partner_view.xml, with possibly also its _fields_view_get override if needed, to accomplish the same UX than the partner view

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hi @ivantodorovich, thanks for your feedback.

The thing is that it really needs the overwritten write method, otherwise it ends up throwing errors due to mismatches in partner fields.

For example, when you change the ZIP code or use the autocomplete in the field service location, saving will throw an error because the partner data does not match the ZIP.

The only solution I found was to overwrite the write method.

Regarding the module name, fieldservice_base_location is fine for me.

Let me know your thoughts!

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks @BernatObrador

Is this covered by the unit tests you wrote?
Meaning, would they fail without the write override?

If we keep it, then, please write a detailed comment explaining the error you get and how this solves it.

def write(self, vals):
    # OVERRIDE to ...
    # ...
    # ...

@BernatObrador BernatObrador force-pushed the 17.0-add-fieldservice_address_autocomplete branch from 9a2c51b to 70675a7 Compare August 22, 2025 07:36
@BernatObrador BernatObrador force-pushed the 17.0-add-fieldservice_address_autocomplete branch from 70675a7 to 339cac3 Compare August 22, 2025 07:44
@BernatObrador BernatObrador changed the title [17.0][ADD] fieldservice_address_autocomplete: New module fieldservice_address_autocomplete [17.0][ADD] fieldservice_base_location: New module fieldservice_base_location Aug 22, 2025
Comment on lines +48 to +52

@classmethod
def _request_handler(cls, s, r, /, **kw):
"""Don't block external requests."""
return cls._super_send(s, r, **kw)
Copy link
Contributor

Choose a reason for hiding this comment

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

What's this for?

Suggested change
@classmethod
def _request_handler(cls, s, r, /, **kw):
"""Don't block external requests."""
return cls._super_send(s, r, **kw)

class FsmLocation(models.Model):
_inherit = "fsm.location"

def write(self, vals):
Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks @BernatObrador

Is this covered by the unit tests you wrote?
Meaning, would they fail without the write override?

If we keep it, then, please write a detailed comment explaining the error you get and how this solves it.

def write(self, vals):
    # OVERRIDE to ...
    # ...
    # ...

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants