-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge commit 'refs/pull/144/head' of github.com:acsone/acsone-addons …
…into 10.0-lih_master
- Loading branch information
Showing
17 changed files
with
144 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from . import models |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# -*- coding: utf-8 -*- | ||
# Copyright 2017 ACSONE SA/NV | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
|
||
{ | ||
'name': 'Mail Record Creation Partner Notification', | ||
'description': """ | ||
Provides a model to inherit to notify partners when | ||
a record is created""", | ||
'version': '10.0.1.0.0', | ||
'license': 'AGPL-3', | ||
'author': 'ACSONE SA/NV', | ||
'website': 'https://www.acsone.eu', | ||
'depends': [ | ||
'partner_to_notify', | ||
], | ||
'data': [ | ||
], | ||
'demo': [ | ||
], | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from . import mail_partner_notification |
39 changes: 39 additions & 0 deletions
39
mail_record_creation_partner_notification/models/mail_partner_notification.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# -*- coding: utf-8 -*- | ||
# Copyright 2017 ACSONE SA/NV | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
|
||
from odoo import api, models | ||
|
||
|
||
class MailPartnerNotification(models.AbstractModel): | ||
|
||
_name = 'mail.partner.notification.mixin' | ||
_description = 'Mail Partner Notification (Abstract)' | ||
|
||
_subscribe_notified_partner_on_creation = True | ||
|
||
@api.model | ||
def create(self, values): | ||
partners_to_notify = self.get_partners_to_notify_on_creation(values) | ||
if partners_to_notify: | ||
self = self.with_context(partners_to_notify=partners_to_notify.ids) | ||
record = super(MailPartnerNotification, self).create(values) | ||
record.subscribe_partners(partners_to_notify) | ||
return record | ||
|
||
@api.model | ||
def get_partners_to_notify_on_creation(self, values): | ||
""" | ||
Inherit this method to get partners to notify when a record | ||
is created. | ||
:param values: creation values | ||
:return: recordset('res.partner') | ||
""" | ||
return self.env['res.partner'] | ||
|
||
@api.multi | ||
def subscribe_partners(self, partners): | ||
self.ensure_one() | ||
if not self._subscribe_notified_partner_on_creation or not partners: | ||
return | ||
self.message_subscribe(partner_ids=partners.ids) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from . import models |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# -*- coding: utf-8 -*- | ||
# Copyright 2017 ACSONE SA/NV | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
|
||
{ | ||
'name': 'Mail Partner To Notify', | ||
'description': """ | ||
Allow to force partners to be notified when posting a message | ||
on a record.""", | ||
'version': '10.0.1.0.0', | ||
'license': 'AGPL-3', | ||
'author': 'ACSONE SA/NV', | ||
'website': 'https://www.acsone.eu', | ||
'depends': [ | ||
'mail', | ||
], | ||
'data': [ | ||
], | ||
'demo': [ | ||
], | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
from . import mail_message | ||
from . import res_partner |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# -*- coding: utf-8 -*- | ||
# Copyright 2017 ACSONE SA/NV | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
|
||
from odoo import api, models | ||
|
||
|
||
class MailMessage(models.Model): | ||
|
||
_inherit = 'mail.message' | ||
|
||
@api.model | ||
def create(self, values): | ||
partners_to_notify = self.env.context.get('partners_to_notify') | ||
if partners_to_notify: | ||
partner_ids = values.get('partner_ids', []) | ||
for partner_id in partners_to_notify: | ||
partner_ids.append((4, partner_id)) | ||
values['partner_ids'] = partner_ids | ||
return super(MailMessage, self).create(values) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# -*- coding: utf-8 -*- | ||
# Copyright 2017 ACSONE SA/NV | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
|
||
from odoo import api, models | ||
|
||
|
||
class ResPartner(models.Model): | ||
|
||
_inherit = 'res.partner' | ||
|
||
@api.multi | ||
def _notify(self, message, force_send=False, send_after_commit=True, | ||
user_signature=True): | ||
partners_to_notify = self.env.context.get('partners_to_notify') | ||
if partners_to_notify: | ||
self = self.browse(partners_to_notify) | ||
super(ResPartner, self)._notify( | ||
message, force_send=force_send, | ||
send_after_commit=send_after_commit, user_signature=user_signature) |
1 change: 1 addition & 0 deletions
1
setup/mail_record_creation_partner_notification/odoo/__init__.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
__import__('pkg_resources').declare_namespace(__name__) |
1 change: 1 addition & 0 deletions
1
setup/mail_record_creation_partner_notification/odoo/addons/__init__.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
__import__('pkg_resources').declare_namespace(__name__) |
1 change: 1 addition & 0 deletions
1
...ecord_creation_partner_notification/odoo/addons/mail_record_creation_partner_notification
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../../../../mail_record_creation_partner_notification |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import setuptools | ||
|
||
setuptools.setup( | ||
setup_requires=['setuptools-odoo'], | ||
odoo_addon=True, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
__import__('pkg_resources').declare_namespace(__name__) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
__import__('pkg_resources').declare_namespace(__name__) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../../../../partner_to_notify |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import setuptools | ||
|
||
setuptools.setup( | ||
setup_requires=['setuptools-odoo'], | ||
odoo_addon=True, | ||
) |