Raimon Esteve (Zikzakmedia) avatar Raimon Esteve (Zikzakmedia) committed 4c3acad

Register methods + browse/searc + name object

Comments (0)

Files changed (3)

+        ActionWizard,
+        Template,
         module='electronic_mail_wizard', type_='model')
 #This file is part electronic_mail_wizard module for Tryton.
 #The COPYRIGHT file at the top level of this repository contains 
 #the full copyright notices and license terms.
-from trytond.model import ModelView, ModelSQL, fields
+from trytond.model import fields
+from trytond.pool import PoolMeta
 __all__ = ['ActionWizard']
+__metaclass__ = PoolMeta
-class ActionWizard(ModelSQL, ModelView):
+class ActionWizard:
     __name__ = 'ir.action.wizard'
     template = fields.One2Many("electronic.mail.template", 'wizard', 'Template')


     def render(self, template, record, values):
         '''Renders the template and returns as email object
-        :param template: Browse Record of the template
-        :param record: Browse Record of the template
+        :param template: Object of the template
+        :param record: Object of the template
         :param values: Dicctionary values
         :return: 'email.message.Message' instance
             language = Template.eval(template, template.language, record)
         with Transaction().set_context(language = language):
-            template = Template.browse(template.id)
+            template = Template(template.id)
             message['from_'] = Template.eval(template, values['from_'], record)
             message['to'] = Template.eval(template, values['to'], record)
             plain = Template.eval(template, values['plain'], record)
             if template.signature:
                 User = Pool().get('res.user')
-                user = User.browse(Transaction().user)
+                user = User(Transaction().user)
                 if user.signature:
                     signature = user.signature.encode("ASCII", 'ignore')
                     plain = '%s\n--\n%s' % (plain, signature)
         wizards = Wizard.search(['wiz_name','=',name])
         if not len(wizards) > 0:
             return default
-        wizard = Wizard.browse(wizards[0])
+        wizard = Wizard(wizards[0])
         if not wizard.template:
         template = wizard.template[0]
             default['subject'] = template.subject
             default['plain'] = template.plain
         else: #show fields with rendered tags
-            record = Pool().get(template.model.model).browse(active_ids[0]) 
+            record = Pool().get(template.model.model)(active_ids[0]) 
             default['to'] = Template.eval(template, template.to, record)
             default['cc'] = Template.eval(template, template.cc, record)
             default['bcc'] = Template.eval(template, template.bcc, record)
         model = self.start.model
         for active_id in Transaction().context.get('active_ids'):
-            record = Pool().get(model.model).browse(active_id)
+            record = Pool().get(model.model)(active_id)
             values = {}
             values['from_'] = self.start.from_
             values['to'] = self.start.to
     __name__ = "electronic_mail_wizard.example"
     def default_start(self, fields):
-        default = self.render_fields(self._name)
+        default = self.render_fields(self.__name__)
         return default
     def transition_send(self):
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.