Browse Source

⬆️1️⃣2️⃣ mail_multi_website

pull/167/head
KolushovAlexandr 6 years ago
parent
commit
f2e5e57847
No known key found for this signature in database GPG Key ID: C3E04B793421FD2
  1. 10
      mail_multi_website/README.rst
  2. 6
      mail_multi_website/__manifest__.py
  3. 4
      mail_multi_website/doc/index.rst
  4. 9
      mail_multi_website/models/ir_property.py
  5. 2
      mail_multi_website/models/mail_template.py
  6. 2
      mail_multi_website/models/res_users.py
  7. 8
      mail_multi_website/tests/test_fetch.py
  8. 2
      mail_multi_website/tests/test_mail_model.py
  9. 23
      mail_multi_website/tests/test_render.py

10
mail_multi_website/README.rst

@ -40,7 +40,7 @@ Maintainers
To get a guaranteed support
you are kindly requested to purchase the module
at `odoo apps store <https://apps.odoo.com/apps/modules/11.0/mail_multi_website/>`__.
at `odoo apps store <https://apps.odoo.com/apps/modules/12.0/mail_multi_website/>`__.
Thank you for understanding!
@ -49,14 +49,14 @@ Maintainers
Further information
===================
Demo: http://runbot.it-projects.info/demo/mail-addons/11.0
Demo: http://runbot.it-projects.info/demo/mail-addons/12.0
HTML Description: https://apps.odoo.com/apps/modules/11.0/mail_multi_website/
HTML Description: https://apps.odoo.com/apps/modules/12.0/mail_multi_website/
Usage instructions: `<doc/index.rst>`_
Changelog: `<doc/changelog.rst>`_
Notifications on updates: `via Atom <https://github.com/it-projects-llc/mail-addons/commits/11.0/mail_multi_website.atom>`_, `by Email <https://blogtrottr.com/?subscribe=https://github.com/it-projects-llc/mail-addons/commits/11.0/mail_multi_website.atom>`_
Notifications on updates: `via Atom <https://github.com/it-projects-llc/mail-addons/commits/12.0/mail_multi_website.atom>`_, `by Email <https://blogtrottr.com/?subscribe=https://github.com/it-projects-llc/mail-addons/commits/12.0/mail_multi_website.atom>`_
Tested on Odoo 11.0 4d0a1330e05bd688265bea14df4ad12838f9f2d7
Tested on Odoo 12.0 80cef9e8c52ff7dc0715a7478a2288d3de7065df

6
mail_multi_website/__manifest__.py

@ -1,4 +1,5 @@
# Copyright 2018 Ivan Yelizariev <https://it-projects.info/team/yelizariev>
# Copyright 2018 Kolushov Alexandr <https://it-projects.info/team/KolushovAlexandr>
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html).
{
"name": """Email Addresses and Templates per Website""",
@ -6,7 +7,7 @@
"category": "Discuss",
"live_test_url": "http://apps.it-projects.info/shop/product/website-multi-company?version=11.0",
"images": ["images/main.jpg"],
"version": "11.0.1.0.0",
"version": "12.0.1.0.0",
"application": False,
"author": "IT-Projects LLC, Ivan Yelizariev",
@ -20,6 +21,7 @@
"ir_config_parameter_multi_company",
"web_website",
"mail",
"test_mail",
],
"external_dependencies": {"python": [], "bin": []},
"data": [
@ -36,7 +38,7 @@
"uninstall_hook": "uninstall_hook",
"auto_install": False,
"installable": False,
"installable": True,
# "demo_title": "Email Addresses per Website",
# "demo_addons": [

4
mail_multi_website/doc/index.rst

@ -48,7 +48,7 @@ Note. If related record (e.g. ``sale.order``) has field ``company_id`` or ``webs
Alias domain per website
------------------------
Configure ``mail.catchall.domain`` per website. See Documentation of the module `Context-dependent values in System Parameters<https://apps.odoo.com/apps/modules/10.0/ir_config_parameter_multi_company/>`__.
Configure ``mail.catchall.domain`` per website. See Documentation of the module `Context-dependent values in System Parameters<https://apps.odoo.com/apps/modules/12.0/ir_config_parameter_multi_company/>`__.
Outgoing mails servers per
--------------------------
@ -61,7 +61,7 @@ If each domain has different Outgoing Mail Server you need following adjustments
Properties
----------
To review properties by website use menu ``[[ Settings ]] >> Technical >> Parameters >> Company Properties``. See **How it works** in Documentation of module `Website Switcher in Backend<https://apps.odoo.com/apps/modules/10.0/web_website/>`__.
To review properties by website use menu ``[[ Settings ]] >> Technical >> Parameters >> Company Properties``. See **How it works** in Documentation of module `Website Switcher in Backend<https://apps.odoo.com/apps/modules/12.0/web_website/>`__.
Usage
=====

9
mail_multi_website/models/ir_property.py

@ -1,4 +1,5 @@
# Copyright 2018 Ivan Yelizariev <https://it-projects.info/team/yelizariev>
# Copyright 2018 Kolushov Alexandr <https://it-projects.info/team/KolushovAlexandr>
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html).
from odoo import models, api
@ -10,10 +11,10 @@ class IrProperty(models.Model):
def write(self, vals):
res = super(IrProperty, self).write(vals)
field_object_list = [
self.env.ref('base.field_res_users_email'),
self.env.ref('mail.field_mail_template_body_html'),
self.env.ref('mail.field_mail_template_mail_server_id'),
self.env.ref('mail.field_mail_template_report_template'),
self.env.ref('base.field_res_users__email'),
self.env.ref('mail.field_mail_template__body_html'),
self.env.ref('mail.field_mail_template__mail_server_id'),
self.env.ref('mail.field_mail_template__report_template'),
]
for fobj in field_object_list:
self._update_db_value_website_dependent(fobj)

2
mail_multi_website/models/mail_template.py

@ -43,7 +43,7 @@ class MailTemplate(models.Model):
return res
@api.model
def render_template(self, template_txt, model, res_ids, post_process=False):
def _render_template(self, template_txt, model, res_ids, post_process=False):
"""Override to add website to context"""
multi_mode = True
if isinstance(res_ids, pycompat.integer_types):

2
mail_multi_website/models/res_users.py

@ -18,7 +18,7 @@ class User(models.Model):
signature = fields.Html(company_dependent=True, website_dependent=True)
# extra field to detach email field from res.partner
email = fields.Char(related='email_multi_website', inherited=False)
email = fields.Char(string='Multi Website Email', related='email_multi_website', inherited=False)
email_multi_website = fields.Char(company_dependent=True, website_dependent=True)
@api.model

8
mail_multi_website/tests/test_fetch.py

@ -1,8 +1,9 @@
# Copyright 2018 Ivan Yelizariev <https://it-projects.info/team/yelizariev>
# Copyright 2018 Kolushov Alexandr <https://it-projects.info/team/KolushovAlexandr>
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html).
from odoo.addons.mail.tests.common import TestMail
from odoo.addons.test_mail.tests.test_mail_mail import TestMail
from odoo.tools import mute_logger
from odoo.addons.mail.tests.test_mail_gateway import MAIL_TEMPLATE
from odoo.addons.test_mail.data.test_mail_data import MAIL_TEMPLATE
class TestFetch(TestMail):
@ -21,7 +22,7 @@ class TestFetch(TestMail):
self.website.company_id = self.company
# copy-paste from mail.tests.test_mail_gateway
mail_test_model = self.env['ir.model']._get('mail.test')
mail_test_model = self.env['ir.model']._get('mail.test.simple')
# groups@.. will cause the creation of new mail.test
self.alias = self.env['mail.alias'].create({
'alias_name': 'groups',
@ -36,6 +37,5 @@ class TestFetch(TestMail):
# Test: one group created by mailgateway administrator
self.assertEqual(len(new_groups), 1, 'message_process: a new mail.test should have been created')
self.assertEqual(new_groups.website_id, self.website, 'New record is created with wrong website')
self.assertEqual(new_groups.company_id, self.company, 'New record is created with wrong company')

2
mail_multi_website/tests/test_mail_model.py

@ -4,7 +4,7 @@ from odoo import models, fields
class MailTest(models.Model):
_inherit = 'mail.test'
_inherit = 'mail.test.simple'
company_id = fields.Many2one('res.company', default=lambda self: self.env['res.company']._company_default_get())
website_id = fields.Many2one('website', default=lambda self: self.env['website'].browse(self.env.context.get('website_id')))

23
mail_multi_website/tests/test_render.py

@ -1,8 +1,9 @@
# Copyright 2018 Ivan Yelizariev <https://it-projects.info/team/yelizariev>
# Copyright 2018 Kolushov Alexandr <https://it-projects.info/team/KolushovAlexandr>
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html).
import base64
from odoo.addons.mail.tests.common import TestMail
from odoo.addons.test_mail.tests.test_mail_mail import TestMail
class TestRender(TestMail):
@ -28,6 +29,7 @@ class TestRender(TestMail):
})
self.website.mail_server_id = self.mail_server_id
user_admin = self.env.ref('base.user_admin')
# copy-paste from mail.tests.test_mail_template
self._attachments = [{
'name': '_Test_First',
@ -35,15 +37,17 @@ class TestRender(TestMail):
'first.txt',
'datas': base64.b64encode(b'My first attachment'),
'res_model': 'res.partner',
'res_id': self.user_admin.partner_id.id
'res_id': user_admin.partner_id.id
}, {
'name': '_Test_Second',
'datas_fname': 'second.txt',
'datas': base64.b64encode(b'My second attachment'),
'res_model': 'res.partner',
'res_id': self.user_admin.partner_id.id
'res_id': user_admin.partner_id.id
}]
self.partner_1 = self.env['res.partner'].create({'name': 'partner_1'})
self.partner_2 = self.env['res.partner'].create({'name': 'partner_2'})
self.email_1 = 'test1@example.com'
self.email_2 = 'test2@example.com'
self.email_3 = self.partner_1.email
@ -71,6 +75,16 @@ class TestRender(TestMail):
"""Mail values are per website"""
self.env.user.backend_website_id = None
TestModel = self.env['mail.test'].with_context({
'mail_create_nolog': True,
'mail_create_nosubscribe': True,
})
self.test_pigs = TestModel.create({
'name': 'Pigs',
'description': 'Fans of Pigs, unite !',
'alias_name': 'pigs',
'alias_contact': 'followers',
})
# sending without website
mail_id = self.email_template.send_mail(self.test_pigs.id)
@ -87,7 +101,8 @@ class TestRender(TestMail):
# copy-pasted tests
self.assertEqual(mail.email_to, self.email_template.email_to)
self.assertEqual(mail.email_cc, self.email_template.email_cc)
# for some reason self.email_template.email_cc might return u'False'
self.assertEqual(mail.email_cc or 'False', self.email_template.email_cc or 'False')
self.assertEqual(mail.recipient_ids, self.partner_2 | self.user_employee.partner_id)
# sending from frontend

Loading…
Cancel
Save