diff --git a/odoo_google_contact_integration/__manifest__.py b/odoo_google_contact_integration/__manifest__.py index 44775625c..a2f2d6a31 100644 --- a/odoo_google_contact_integration/__manifest__.py +++ b/odoo_google_contact_integration/__manifest__.py @@ -21,7 +21,7 @@ ############################################################################### { 'name': "Google Contact Connector", - 'version': '18.0.1.0.1', + 'version': '18.0.1.0.2', "category": "Extra Tools", 'summary': """Synchronize Google Contacts (Import/Export).""", 'description': 'The Google Contact Connector module helps you import Google' diff --git a/odoo_google_contact_integration/doc/RELEASE_NOTES.md b/odoo_google_contact_integration/doc/RELEASE_NOTES.md index 719825dd3..82afbf0b5 100644 --- a/odoo_google_contact_integration/doc/RELEASE_NOTES.md +++ b/odoo_google_contact_integration/doc/RELEASE_NOTES.md @@ -3,4 +3,9 @@ #### Version 18.0.1.0.0 #### ADD - Initial commit for Google Contact Connector -- Fixed the issue of default country and state assignment during contact import \ No newline at end of file +- Fixed the issue of default country and state assignment during contact import + +#### 8.05.2025 +#### Version 18.0.1.0.2 +#### BUG FIX +- Fixed the issue with importing more than 1000 Google contacts by adding pagination support. \ No newline at end of file diff --git a/odoo_google_contact_integration/models/res_company.py b/odoo_google_contact_integration/models/res_company.py index 0b2b3d489..d2107c28d 100644 --- a/odoo_google_contact_integration/models/res_company.py +++ b/odoo_google_contact_integration/models/res_company.py @@ -115,19 +115,29 @@ class ResCompany(models.Model): ) def action_import_google_contacts(self): - """IMPORT Contacts FROM Google TO ODOO""" - url = ("https://people.googleapis.com/v1/people/me/" - "connections?personFields=names,addresses," - "emailAddresses,phoneNumbers&pageSize=1000") + """IMPORT Contacts FROM Google TO ODOO with pagination support""" + base_url = ("https://people.googleapis.com/v1/people/me/" + "connections?personFields=names,addresses," + "emailAddresses,phoneNumbers&pageSize=1000") headers = { 'Authorization': f'Bearer {self.contact_company_access_token}', 'Content-Type': 'application/json' } - response = requests.get(url, headers=headers) - if response.status_code == 200: - data = response.json().get('connections', []) - partners = [] - for connection in data: + next_page_token = None + partners = [] + + while True: + url = base_url + if next_page_token: + url += f"&pageToken={next_page_token}" + response = requests.get(url, headers=headers) + if response.status_code != 200: + error_message = f"Failed to import contact. Error: {response.text}" + raise ValidationError(error_message) + + data = response.json() + connections = data.get('connections', []) + for connection in connections: cnt_rsr_name = connection.get('resourceName', '') etag = connection.get('etag', '') names = connection.get('names', [{}])[0] @@ -151,7 +161,8 @@ class ResCompany(models.Model): if addresses: if country_code: - country_record = self.env['res.country'].search([('code', 'ilike', country_code)], limit=1) + country_record = self.env['res.country'].search( + [('code', 'ilike', country_code)], limit=1) country_id = country_record.id if country_record else False else: country_id = False @@ -180,19 +191,23 @@ class ResCompany(models.Model): existing_partner.write(partner_vals) else: partners.append(partner_vals) - if partners: - self.env['res.partner'].create(partners) - _logger.info("Contact imported successfully!") - return { - 'type': 'ir.actions.client', - 'tag': 'display_notification', - 'params': { - 'type': 'danger', - 'sticky': False, - 'message': _("Contact imported successfully!"), - 'next': {'type': 'ir.actions.act_window_close'}, - } + + if data.get('nextPageToken'): + next_page_token = data['nextPageToken'] + else: + break + + if partners: + self.env['res.partner'].create(partners) + _logger.info("Contacts imported successfully!") + + return { + 'type': 'ir.actions.client', + 'tag': 'display_notification', + 'params': { + 'type': 'success', + 'sticky': False, + 'message': _("Contacts imported successfully!"), + 'next': {'type': 'ir.actions.act_window_close'}, } - else: - error_message = f"Failed to import contact. Error: {response.text}" - raise ValidationError(error_message) + } diff --git a/odoo_google_contact_integration/static/description/index.html b/odoo_google_contact_integration/static/description/index.html index eae1c7c18..dc08010c2 100644 --- a/odoo_google_contact_integration/static/description/index.html +++ b/odoo_google_contact_integration/static/description/index.html @@ -1270,6 +1270,36 @@ class="tab-pane fade show" id="releases" role="tabpanel"> +
+
+

+ Latest Release 18.0.1.0.2 +

+ + 8th May, 2025 + +
+
+
+
+
+ Updt +
+
+
+
    +
  • + Fixed the issue with importing more than 1000 Google contacts by adding pagination support. +
  • + +
+
+
+
+
+
+