[MOVE] website_mail: moved model-related files inside a models directory.
authorThibault Delavallée <tde@openerp.com>
Fri, 11 Oct 2013 10:00:57 +0000 (12:00 +0200)
committerThibault Delavallée <tde@openerp.com>
Fri, 11 Oct 2013 10:00:57 +0000 (12:00 +0200)
This is done to match the new module organization we want to set
for OpenERP modules. Model-related files should lie in a models
directory.

bzr revid: tde@openerp.com-20131011100057-bpe5620omyjsj0y0

addons/website_mail/__init__.py
addons/website_mail/mail_message.py [deleted file]
addons/website_mail/mail_thread.py [deleted file]
addons/website_mail/models/__init__.py [new file with mode: 0644]
addons/website_mail/models/mail_message.py [new file with mode: 0644]
addons/website_mail/models/mail_thread.py [new file with mode: 0644]

index e20643c..708d6ce 100644 (file)
@@ -20,5 +20,4 @@
 ##############################################################################
 
 import controllers
-import mail_message
-import mail_thread
+import models
diff --git a/addons/website_mail/mail_message.py b/addons/website_mail/mail_message.py
deleted file mode 100644 (file)
index 41c4e6a..0000000
+++ /dev/null
@@ -1,65 +0,0 @@
-# -*- coding: utf-8 -*-
-##############################################################################
-#
-#    OpenERP, Open Source Management Solution
-#    Copyright (C) 2013-Today OpenERP SA (<http://www.openerp.com>).
-#
-#    This program is free software: you can redistribute it and/or modify
-#    it under the terms of the GNU Affero General Public License as
-#    published by the Free Software Foundation, either version 3 of the
-#    License, or (at your option) any later version.
-#
-#    This program is distributed in the hope that it will be useful,
-#    but WITHOUT ANY WARRANTY; without even the implied warranty of
-#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-#    GNU Affero General Public License for more details.
-#
-#    You should have received a copy of the GNU Affero General Public License
-#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
-#
-##############################################################################
-
-from openerp.tools.translate import _
-from openerp.osv import osv, fields
-
-
-class MailMessage(osv.Model):
-    _inherit = 'mail.message'
-
-    _columns = {
-        'website_published': fields.boolean(
-            'Publish', help="Publish on the website as a blog"
-        ),
-    }
-
-    _defaults = {
-        'website_published': True,
-    }
-
-    def _search(self, cr, uid, args, offset=0, limit=None, order=None,
-                context=None, count=False, access_rights_uid=None):
-        """ Override that adds specific access rights of mail.message, to restrict
-        messages to published messages for public users. """
-        group_ids = self.pool.get('res.users').browse(cr, uid, uid, context=context).groups_id
-        group_user_id = self.pool.get("ir.model.data").get_object_reference(cr, uid, 'base', 'group_public')[1]
-        if group_user_id in [group.id for group in group_ids]:
-            args = ['&', ('website_published', '=', True)] + list(args)
-
-        return super(MailMessage, self)._search(cr, uid, args, offset=offset, limit=limit, order=order,
-                                                context=context, count=False, access_rights_uid=access_rights_uid)
-
-    def check_access_rule(self, cr, uid, ids, operation, context=None):
-        """ Add Access rules of mail.message for non-employee user:
-            - read:
-                - raise if the type is comment and subtype NULL (internal note)
-        """
-        group_ids = self.pool.get('res.users').browse(cr, uid, uid, context=context).groups_id
-        group_user_id = self.pool.get("ir.model.data").get_object_reference(cr, uid, 'base', 'group_public')[1]
-        if group_user_id in [group.id for group in group_ids]:
-            cr.execute('SELECT DISTINCT id FROM "%s" WHERE website_published IS FALSE AND id = ANY (%%s)' % (self._table), (ids,))
-            if cr.fetchall():
-                raise osv.except_osv(
-                    _('Access Denied'),
-                    _('The requested operation cannot be completed due to security restrictions. Please contact your system administrator.\n\n(Document type: %s, Operation: %s)') % (self._description, operation))
-
-        return super(MailMessage, self).check_access_rule(cr, uid, ids=ids, operation=operation, context=context)
diff --git a/addons/website_mail/mail_thread.py b/addons/website_mail/mail_thread.py
deleted file mode 100644 (file)
index c88fd03..0000000
+++ /dev/null
@@ -1,37 +0,0 @@
-# -*- coding: utf-8 -*-
-##############################################################################
-#
-#    OpenERP, Open Source Management Solution
-#    Copyright (C) 2013-Today OpenERP SA (<http://www.openerp.com>).
-#
-#    This program is free software: you can redistribute it and/or modify
-#    it under the terms of the GNU Affero General Public License as
-#    published by the Free Software Foundation, either version 3 of the
-#    License, or (at your option) any later version.
-#
-#    This program is distributed in the hope that it will be useful,
-#    but WITHOUT ANY WARRANTY; without even the implied warranty of
-#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-#    GNU Affero General Public License for more details.
-#
-#    You should have received a copy of the GNU Affero General Public License
-#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
-#
-##############################################################################
-
-from openerp.osv import osv, fields
-
-
-class MailThread(osv.Model):
-    _inherit = 'mail.thread'
-
-    _columns = {
-        'website_message_ids': fields.one2many(
-            'mail.message', 'res_id',
-            domain=lambda self: [
-                '&', ('model', '=', self._name), ('type', '=', 'comment')
-            ],
-            string='Website Messages',
-            help="Website communication history",
-        ),
-    }
diff --git a/addons/website_mail/models/__init__.py b/addons/website_mail/models/__init__.py
new file mode 100644 (file)
index 0000000..f8d6037
--- /dev/null
@@ -0,0 +1,2 @@
+import mail_message
+import mail_thread
diff --git a/addons/website_mail/models/mail_message.py b/addons/website_mail/models/mail_message.py
new file mode 100644 (file)
index 0000000..41c4e6a
--- /dev/null
@@ -0,0 +1,65 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+#    OpenERP, Open Source Management Solution
+#    Copyright (C) 2013-Today OpenERP SA (<http://www.openerp.com>).
+#
+#    This program is free software: you can redistribute it and/or modify
+#    it under the terms of the GNU Affero General Public License as
+#    published by the Free Software Foundation, either version 3 of the
+#    License, or (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU Affero General Public License for more details.
+#
+#    You should have received a copy of the GNU Affero General Public License
+#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
+#
+##############################################################################
+
+from openerp.tools.translate import _
+from openerp.osv import osv, fields
+
+
+class MailMessage(osv.Model):
+    _inherit = 'mail.message'
+
+    _columns = {
+        'website_published': fields.boolean(
+            'Publish', help="Publish on the website as a blog"
+        ),
+    }
+
+    _defaults = {
+        'website_published': True,
+    }
+
+    def _search(self, cr, uid, args, offset=0, limit=None, order=None,
+                context=None, count=False, access_rights_uid=None):
+        """ Override that adds specific access rights of mail.message, to restrict
+        messages to published messages for public users. """
+        group_ids = self.pool.get('res.users').browse(cr, uid, uid, context=context).groups_id
+        group_user_id = self.pool.get("ir.model.data").get_object_reference(cr, uid, 'base', 'group_public')[1]
+        if group_user_id in [group.id for group in group_ids]:
+            args = ['&', ('website_published', '=', True)] + list(args)
+
+        return super(MailMessage, self)._search(cr, uid, args, offset=offset, limit=limit, order=order,
+                                                context=context, count=False, access_rights_uid=access_rights_uid)
+
+    def check_access_rule(self, cr, uid, ids, operation, context=None):
+        """ Add Access rules of mail.message for non-employee user:
+            - read:
+                - raise if the type is comment and subtype NULL (internal note)
+        """
+        group_ids = self.pool.get('res.users').browse(cr, uid, uid, context=context).groups_id
+        group_user_id = self.pool.get("ir.model.data").get_object_reference(cr, uid, 'base', 'group_public')[1]
+        if group_user_id in [group.id for group in group_ids]:
+            cr.execute('SELECT DISTINCT id FROM "%s" WHERE website_published IS FALSE AND id = ANY (%%s)' % (self._table), (ids,))
+            if cr.fetchall():
+                raise osv.except_osv(
+                    _('Access Denied'),
+                    _('The requested operation cannot be completed due to security restrictions. Please contact your system administrator.\n\n(Document type: %s, Operation: %s)') % (self._description, operation))
+
+        return super(MailMessage, self).check_access_rule(cr, uid, ids=ids, operation=operation, context=context)
diff --git a/addons/website_mail/models/mail_thread.py b/addons/website_mail/models/mail_thread.py
new file mode 100644 (file)
index 0000000..c88fd03
--- /dev/null
@@ -0,0 +1,37 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+#    OpenERP, Open Source Management Solution
+#    Copyright (C) 2013-Today OpenERP SA (<http://www.openerp.com>).
+#
+#    This program is free software: you can redistribute it and/or modify
+#    it under the terms of the GNU Affero General Public License as
+#    published by the Free Software Foundation, either version 3 of the
+#    License, or (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU Affero General Public License for more details.
+#
+#    You should have received a copy of the GNU Affero General Public License
+#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
+#
+##############################################################################
+
+from openerp.osv import osv, fields
+
+
+class MailThread(osv.Model):
+    _inherit = 'mail.thread'
+
+    _columns = {
+        'website_message_ids': fields.one2many(
+            'mail.message', 'res_id',
+            domain=lambda self: [
+                '&', ('model', '=', self._name), ('type', '=', 'comment')
+            ],
+            string='Website Messages',
+            help="Website communication history",
+        ),
+    }