Commits

Raimon Esteve (Zikzakmedia) committed cf72ee7

Revision code version 2.6

Comments (0)

Files changed (4)

 #This file is part electronic_mail module for Tryton.
 #The COPYRIGHT file at the top level of this repository contains 
 #the full copyright notices and license terms.
-
 from trytond.pool import Pool
 from electronic_mail import *
 

electronic_mail.py

             'mailbox', 'user', 'Write Users')
 
 
-
 class MailboxParent(ModelSQL):
     'Mailbox - parent - Mailbox'
     __name__ = 'electronic.mail.mailbox.mailbox'
             ondelete='CASCADE', required=True, select=1)
 
 
-
 class ReadUser(ModelSQL):
     'Electronic Mail - read - User'
     __name__ = 'electronic.mail.mailbox.read.res.user'
             required=True, select=1)
 
 
-
 class WriteUser(ModelSQL):
     'Mailbox - write - User'
     __name__ = 'electronic.mail.mailbox.write.res.user'
             required=True, select=1)
 
 
-
 class ElectronicMail(ModelSQL, ModelView):
     "E-mail"
     __name__ = 'electronic.mail'
     def search_mailbox_users(self, name, clause):
         return [('mailbox.' + name[8:],) + clause[1:]]
 
-    def _get_email(self, electronic_mail):
+    @staticmethod
+    def _get_email(electronic_mail):
         """
         Returns the email object from reading the FS
         :param electronic_mail: Browse Record of the mail
             digest = md5.new(data).hexdigest()
         return digest
 
+    @classmethod
     def create_from_email(self, mail, mailbox):
         """
         Creates a mail record from a given mail
         :param mail: email object
         :param mailbox: ID of the mailbox
         """
-        header_obj = Pool().get('electronic.mail.header')
+        Header = Pool().get('electronic.mail.header')
         email_date = mail.get('date') and datetime.fromtimestamp(
                 mktime(parsedate(mail.get('date'))))
         values = {
             'size': getsizeof(mail.as_string()),
             }
         create_id = self.create(values)
-        header_obj.create_from_email(mail, create_id)
+        Header.create_from_email(mail, create_id)
         return create_id
 
-    @classmethod
-    def get_email_valid(cls, email):
+    @staticmethod
+    def get_email_valid(email):
         """Get if email is valid. @ and . characters validation
         :email: str
         return: True or False
     value = fields.Char('Value', help='Value of Header Field')
     electronic_mail = fields.Many2One('electronic.mail', 'e-mail')
 
+    @classmethod
     def create_from_email(self, mail, mail_id):
         """
         :param mail: Email object

electronic_mail.xml

File contents unchanged.

tests/test_electronic_mail.py

File contents unchanged.