Skip to content

Commit

Permalink
Merge pull request #153 from gisce/moves_multicompany_stuff_to_proper…
Browse files Browse the repository at this point in the history
…_module

Mover lógica de multicompany a módulo poweremail_multicompany
  • Loading branch information
ecarreras authored Apr 19, 2024
2 parents e779f4e + f8f885b commit e221ad5
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 28 deletions.
9 changes: 1 addition & 8 deletions poweremail_send_wizard.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)):
Expand Down
27 changes: 7 additions & 20 deletions tests/test_poweremail_mailbox.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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'
Expand Down Expand Up @@ -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
Expand All @@ -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'])





0 comments on commit e221ad5

Please sign in to comment.