From 996de5ecf258e12ace144787f3eef3ecacfe26e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emili=20Garc=C3=ADa?= Date: Thu, 18 Apr 2024 13:09:26 +0200 Subject: [PATCH 1/3] Moves multicompny logic to proper module poweremail_multicompany --- poweremail_send_wizard.py | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/poweremail_send_wizard.py b/poweremail_send_wizard.py index aadc240..fb48b69 100644 --- a/poweremail_send_wizard.py +++ b/poweremail_send_wizard.py @@ -55,14 +55,7 @@ def _get_accounts(self, cr, uid, context=None): ) logger = netsvc.Logger() - if template.enforce_from_account_by_company: - res = [] - for account_for_company in template.enforce_from_account_by_company: - res.append( - (account_for_company.id, '%s (%s)' % (account_for_company.name, account_for_company.email_id)) - ) - return res - elif template.enforce_from_account: + if template.enforce_from_account: return [(template.enforce_from_account.id, '%s (%s)' % (template.enforce_from_account.name, template.enforce_from_account.email_id))] elif (context.get('from', False) and isinstance(context.get('from'), int)): From 56374a8c7ca916d46120342afb9e2ee802b7f5c8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emili=20Garc=C3=ADa?= Date: Fri, 19 Apr 2024 10:44:59 +0200 Subject: [PATCH 2/3] Removes mocked deleted method on test --- tests/test_poweremail_mailbox.py | 23 +++++------------------ 1 file changed, 5 insertions(+), 18 deletions(-) diff --git a/tests/test_poweremail_mailbox.py b/tests/test_poweremail_mailbox.py index 78b32b9..ed8f74d 100644 --- a/tests/test_poweremail_mailbox.py +++ b/tests/test_poweremail_mailbox.py @@ -391,17 +391,12 @@ def generate_mail_with_attachments_and_report_multi_users(self, mock_function): attach_ids = ir_attachment_obj.search(cursor, uid, []) self.assertEqual(len(attach_ids), 5) - - - - @mock.patch('poweremail.poweremail_send_wizard.poweremail_send_wizard.add_template_attachments') @mock.patch('poweremail.poweremail_send_wizard.poweremail_send_wizard.add_attachment_documents') @mock.patch('poweremail.poweremail_send_wizard.poweremail_send_wizard.process_extra_attachment_in_template') @mock.patch('poweremail.poweremail_send_wizard.poweremail_send_wizard.create_report_attachment') @mock.patch('poweremail.poweremail_send_wizard.poweremail_send_wizard.create_mail') - @mock.patch('poweremail.poweremail_send_wizard.poweremail_send_wizard.check_lang') - def test_save_to_mailbox(self, mock_function, mock_function_2, mock_function_3, mock_function_4, mock_function_5, mock_function_6): + def test_save_to_mailbox(self, mock_function, mock_function_2, mock_function_3, mock_function_4, mock_function_5): self.openerp.install_module('giscedata_facturacio') with Transaction().start(self.database) as txn: uid = txn.user @@ -521,14 +516,11 @@ def test_save_to_mailbox(self, mock_function, mock_function_2, mock_function_3, } attachment_report_id = ir_attachment_obj.create(cursor, uid, attach_vals) - mock_function.return_value = "es_ES" - mock_function_2.return_value = mail_id - mock_function_3.return_value = attachment_report_id + mock_function.return_value = mail_id + mock_function_2.return_value = attachment_report_id + mock_function_3.return_value = [] mock_function_4.return_value = [] - mock_function_5.return_value = [] - mock_function_6.return_value = [attachment_id] - - + mock_function_5.return_value = [attachment_id] context = {} context['template_id'] = template_id @@ -546,8 +538,3 @@ def test_save_to_mailbox(self, mock_function, mock_function_2, mock_function_3, self.assertEqual(len(mail_created_vals['pem_attachments_ids']), 2) self.assertIn(attachment_report_id, mail_created_vals['pem_attachments_ids']) self.assertIn(attachment_id, mail_created_vals['pem_attachments_ids']) - - - - - From f8f885b69f77b7acc336bf7de5e96455b0bd9dba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emili=20Garc=C3=ADa?= Date: Fri, 19 Apr 2024 11:50:33 +0200 Subject: [PATCH 3/3] Removes installing module facturacio for just am id --- tests/test_poweremail_mailbox.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/test_poweremail_mailbox.py b/tests/test_poweremail_mailbox.py index ed8f74d..285a371 100644 --- a/tests/test_poweremail_mailbox.py +++ b/tests/test_poweremail_mailbox.py @@ -397,7 +397,6 @@ def generate_mail_with_attachments_and_report_multi_users(self, mock_function): @mock.patch('poweremail.poweremail_send_wizard.poweremail_send_wizard.create_report_attachment') @mock.patch('poweremail.poweremail_send_wizard.poweremail_send_wizard.create_mail') def test_save_to_mailbox(self, mock_function, mock_function_2, mock_function_3, mock_function_4, mock_function_5): - self.openerp.install_module('giscedata_facturacio') with Transaction().start(self.database) as txn: uid = txn.user cursor = txn.cursor @@ -408,7 +407,8 @@ def test_save_to_mailbox(self, mock_function, mock_function_2, mock_function_3, pw_account_obj = self.openerp.pool.get('poweremail.core_accounts') send_wizard_obj = self.openerp.pool.get('poweremail.send.wizard') - fact_id = imd_obj.get_object_reference(cursor, uid, 'giscedata_facturacio', 'factura_0006')[1] + # Dummy value for an invoice id + fact_id = 6 # Agafem un template de prova per posar a l'attachment template_id = imd_obj.get_object_reference( cursor, uid, 'poweremail', 'default_template_poweremail'