Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[14.0][IMP] shopinvader_locomotive: avoid unnecessary partner exports #1578

Open
wants to merge 1 commit into
base: 14.0
Choose a base branch
from

Conversation

henrybackman
Copy link

shopinvader_locomotive: avoid unnecessary partner exports by not executing the export if the updated fields contain only:

  • external_id
  • last_login_time

@henrybackman henrybackman force-pushed the 14.0-shopinvader_locomotive-avoid_unnecessary_partner_exports branch 4 times, most recently from bc97da5 to 95b102a Compare January 20, 2025 10:18
@henrybackman henrybackman marked this pull request as ready for review January 20, 2025 14:08
@skip_if(lambda self, record, **kwargs: self.no_connector_export(record))
def on_record_write(self, record, fields=None):
# skip export if updating only fields that are not relevant
if set(fields).issubset(set(self._get_export_not_triggered_fields())):
Copy link
Contributor

Choose a reason for hiding this comment

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

Could this be an issue?

>>> set(None)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: 'NoneType' object is not iterable

I would check if fields is set first, and _get_export_not_triggered_fields, because it can be overridden to return None or False depending on a company setting in the future, for instance.

Copy link
Author

Choose a reason for hiding this comment

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

Great points. Made modifications and added tests to cover the mentioned scenarios

@henrybackman henrybackman force-pushed the 14.0-shopinvader_locomotive-avoid_unnecessary_partner_exports branch from 95b102a to 8d1fa38 Compare January 21, 2025 08:15
Comment on lines 148 to 153
with patch(
"odoo.addons.shopinvader_locomotive.component.event_listeners.ShopinvaderBindingListener._get_export_not_triggered_fields",
mock_get_export_not_triggered_fields,
):
Copy link
Contributor

Choose a reason for hiding this comment

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

Is pre-commit happy about that?

Suggested change
with patch(
"odoo.addons.shopinvader_locomotive.component.event_listeners.ShopinvaderBindingListener._get_export_not_triggered_fields",
mock_get_export_not_triggered_fields,
):
method_path = (
"odoo.addons.shopinvader_locomotive.component.event_listeners."
"ShopinvaderBindingListener._get_export_not_triggered_fields"
)
with patch(method_path, mock_get_export_not_triggered_fields):

Copy link
Author

Choose a reason for hiding this comment

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

pre-commit issues fixed and changes pass them now

@henrybackman henrybackman force-pushed the 14.0-shopinvader_locomotive-avoid_unnecessary_partner_exports branch from 8d1fa38 to 00afd15 Compare January 21, 2025 13:41
@henrybackman henrybackman force-pushed the 14.0-shopinvader_locomotive-avoid_unnecessary_partner_exports branch from 00afd15 to 5c44d63 Compare January 21, 2025 14:41
@simahawk
Copy link
Contributor

/ocabot merge minor

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.

3 participants