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

Draft
wants to merge 1 commit into
base: 14.0
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions shopinvader_locomotive/component/event_listeners.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,14 @@ class ShopinvaderBindingListener(Component):
def on_record_create(self, record, fields=None):
record.with_delay().export_record(_fields=fields)

def _get_export_not_triggered_fields(self):
return ["external_id", "last_login_time"]

@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())):
return
record.with_delay().export_record(_fields=fields)

def on_record_unlink(self, record):
Expand Down
33 changes: 33 additions & 0 deletions shopinvader_locomotive/tests/test_shopinvader_partner.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,39 @@ def test_no_update_shopinvader_partner_from_odoo(self):
# As we did not updated a field to export, no job should be created
self._check_nbr_job_created(0)

def test_no_update_on_shopinvader_partner_external_id_from_odoo(self):
shop_partner, params = self._create_shopinvader_partner(
self.data, "5a953d6aae1c744cfcfb3cd3"
)
self._init_job_counter()
# write on shop_partner because res_partner doesn't have these fields
shop_partner.write({"external_id": "TEST"})
self._check_nbr_job_created(0)

# partner or shop_partner don't have last_login_time field
# def test_no_update_on_shopinvader_last_login_time_from_odoo(self):
# shop_partner, params = self._create_shopinvader_partner(
# self.data, "5a953d6aae1c744cfcfb3cd3"
# )
# self._init_job_counter()
# partner = shop_partner.record_id
# partner.write({"last_login_time": "2025-01-01 00:00:00"})
# self._check_nbr_job_created(0)

def test_update_on_shopinvader_with_mixed_fields_from_odoo(self):
shop_partner, params = self._create_shopinvader_partner(
self.data, "5a953d6aae1c744cfcfb3cd3"
)
self._init_job_counter()
shop_partner.write({
"name": "TEST",
"external_id": "TEST",
# "last_login_time": "2025-01-01 00:00:00"
})
# self._check_nbr_job_created(1)
self._check_nbr_job_created(2) # duplicate jobs created but still exported
# is this a test issue or a real issue?

def test_binding_access_rights(self):
shop_partner, params = self._create_shopinvader_partner(
self.data, u"5a953d6aae1c744cfcfb3cd3"
Expand Down