Browse Source

MAY 12: [FIX] Bug Fixed 'odoo_google_contact_integration'

pull/346/merge
Cybrosys Technologies 3 months ago
parent
commit
687d451c77
  1. 2
      odoo_google_contact_integration/__manifest__.py
  2. 5
      odoo_google_contact_integration/doc/RELEASE_NOTES.md
  3. 41
      odoo_google_contact_integration/models/res_company.py
  4. 30
      odoo_google_contact_integration/static/description/index.html

2
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'

5
odoo_google_contact_integration/doc/RELEASE_NOTES.md

@ -4,3 +4,8 @@
#### ADD
- Initial commit for Google Contact Connector
- 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.

41
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/"
"""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', [])
next_page_token = None
partners = []
for connection in data:
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 data.get('nextPageToken'):
next_page_token = data['nextPageToken']
else:
break
if partners:
self.env['res.partner'].create(partners)
_logger.info("Contact imported successfully!")
_logger.info("Contacts imported successfully!")
return {
'type': 'ir.actions.client',
'tag': 'display_notification',
'params': {
'type': 'danger',
'type': 'success',
'sticky': False,
'message': _("Contact imported successfully!"),
'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)

30
odoo_google_contact_integration/static/description/index.html

@ -1270,6 +1270,36 @@
class="tab-pane fade show" id="releases"
role="tabpanel">
<!-- Release Notes -->
<div class="row pt-5 m-0">
<div class="col-md-3">
<h4 style="font-size:16px; font-weight:600; color:#514F4F; margin:0; line-height:26px;">
Latest Release 18.0.1.0.2
</h4>
<span style="font-size:14px; color:#7A7979; display:block; margin-bottom:20px;">
8th May, 2025
</span>
</div>
<div class="col-md-8">
<div style="padding:0 0 40px">
<div style="margin:0 0 10px">
<div style="display:inline-block; padding:0px 8px; color:#514F4F; background-color:#FFD8D8; border-radius:20px">
Updt
</div>
</div>
<div class="d-flex m-0"
style="color:#7A7979;">
<ul class="pl-3 mb-0">
<li>
Fixed the issue with importing more than 1000 Google contacts by adding pagination support.
</li>
</ul>
</div>
</div>
<div style="padding:0 0 0; border-bottom:1px solid #E3E3E3">
</div>
</div>
</div>
<div class="row pt-5 m-0">
<div class="col-md-3">
<h4 style="font-size:16px; font-weight:600; color:#514F4F; margin:0; line-height:26px;">

Loading…
Cancel
Save