Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • How to create and Allow to render a QWeb template python-side openerp

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 836
    Comment on it

    In openerp render function returns the 'ir.ui.view' but embellish it with some variables/methods used in reports. param values is additional methods/variables used in the rendering returns is html representation of the template.
    use this code show below in .py file,

    def render(self, cr, uid, ids, template, values=None, context=None):
    
            if values is None:
                values = {}
    
            if context is None:
                context = {}
    
            context = dict(context, inherit_branding=True)  # Tell QWeb to brand the generated html
    
            view_obj = self.pool['ir.ui.view']
    
            user = self.pool['res.users'].browse(cr, uid, uid)
            website = None
            if request and hasattr(request, 'website'):
                if request.website is not None:
                    website = request.website
                    context = dict(context, translatable=context.get('lang') != request.website.default_lang_code)
    
            values.update(
                time=time,
                context_timestamp=lambda t: fields.datetime.context_timestamp(cr, uid, t, context),
                editable=True,
                user=user,
                res_company=user.company_id,
                website=website,
            )
            return view_obj.render(cr, uid, template, values, context=context)
    

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: