From aa0ff1252dd6cdffa8332dc7ee945535a5a8c030 Mon Sep 17 00:00:00 2001 From: Patrick Wilson <36892066+patrickrwilson@users.noreply.github.com> Date: Tue, 5 May 2020 16:21:13 -0500 Subject: [PATCH 1/3] [FIX] partner_multi_relation (Smart Button Error) Fix for error when opening a contact and clicking the smart button. Error Information: File "/opt/odoo/v12/src/partner-contact/partner_multi_relation/models/res_partner.py", line 187, in action_view_relations action['context'].\ AttributeError: 'str' object has no attribute 'update' --- partner_multi_relation/models/res_partner.py | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/partner_multi_relation/models/res_partner.py b/partner_multi_relation/models/res_partner.py index fa1aaa72e..4c7109276 100644 --- a/partner_multi_relation/models/res_partner.py +++ b/partner_multi_relation/models/res_partner.py @@ -184,11 +184,10 @@ class ResPartner(models.Model): 'partner_multi_relation.action_res_partner_relation_all' ).read()[0] action['domain'] = [('id', 'in', relation_ids.ids)] - action['context'].\ - update({'search_default_this_partner_id': contact.id, - 'default_this_partner_id': contact.id, - 'active_model': 'res.partner', - 'active_id': contact.id, - 'active_ids': [contact.id], - 'active_test': False}) + action['context'] = {'search_default_this_partner_id': contact.id, + 'default_this_partner_id': contact.id, + 'active_model': 'res.partner', + 'active_id': contact.id, + 'active_ids': [contact.id], + 'active_test': False} return action From dd72e05c0130fb3cfc5e3f634b9d0a919f379a70 Mon Sep 17 00:00:00 2001 From: Patrick Wilson <36892066+patrickrwilson@users.noreply.github.com> Date: Wed, 6 May 2020 16:52:13 -0500 Subject: [PATCH 2/3] [UPD] Attempt at manipulating context --- partner_multi_relation/models/res_partner.py | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/partner_multi_relation/models/res_partner.py b/partner_multi_relation/models/res_partner.py index 4c7109276..668bd67d7 100644 --- a/partner_multi_relation/models/res_partner.py +++ b/partner_multi_relation/models/res_partner.py @@ -184,10 +184,14 @@ class ResPartner(models.Model): 'partner_multi_relation.action_res_partner_relation_all' ).read()[0] action['domain'] = [('id', 'in', relation_ids.ids)] - action['context'] = {'search_default_this_partner_id': contact.id, - 'default_this_partner_id': contact.id, - 'active_model': 'res.partner', - 'active_id': contact.id, - 'active_ids': [contact.id], - 'active_test': False} + context = action.get('context', '{}').strip()[1:-1] + elements = context.split(',') if context else [] + to_add = ["""'search_default_this_partner_id': contact.id, + 'default_this_partner_id': contact.id, + 'active_model': 'res.partner', + 'active_id': contact.id, + 'active_ids': [contact.id], + 'active_test': False"""] + context = '{' + ', '.join(elements + to_add) + '}' + action['context'] = context return action From 971b84cf8bd79fd4303ab277d31e912d3835dbf5 Mon Sep 17 00:00:00 2001 From: Patrick Wilson <36892066+patrickrwilson@users.noreply.github.com> Date: Fri, 15 May 2020 16:49:28 -0500 Subject: [PATCH 3/3] [FIX] Contact ID Error --- partner_multi_relation/models/res_partner.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/partner_multi_relation/models/res_partner.py b/partner_multi_relation/models/res_partner.py index 668bd67d7..1b2813d1e 100644 --- a/partner_multi_relation/models/res_partner.py +++ b/partner_multi_relation/models/res_partner.py @@ -186,12 +186,12 @@ class ResPartner(models.Model): action['domain'] = [('id', 'in', relation_ids.ids)] context = action.get('context', '{}').strip()[1:-1] elements = context.split(',') if context else [] - to_add = ["""'search_default_this_partner_id': contact.id, - 'default_this_partner_id': contact.id, + to_add = ["""'search_default_this_partner_id': {0}, + 'default_this_partner_id': {0}, 'active_model': 'res.partner', - 'active_id': contact.id, - 'active_ids': [contact.id], - 'active_test': False"""] + 'active_id': {0}, + 'active_ids': [{0}], + 'active_test': False""".format(contact.id)] context = '{' + ', '.join(elements + to_add) + '}' action['context'] = context return action