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)): diff --git a/tests/test_poweremail_mailbox.py b/tests/test_poweremail_mailbox.py index 78b32b9..285a371 100644 --- a/tests/test_poweremail_mailbox.py +++ b/tests/test_poweremail_mailbox.py @@ -391,18 +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): - self.openerp.install_module('giscedata_facturacio') + def test_save_to_mailbox(self, mock_function, mock_function_2, mock_function_3, mock_function_4, mock_function_5): with Transaction().start(self.database) as txn: uid = txn.user cursor = txn.cursor @@ -413,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' @@ -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']) - - - - -