Odoo Help

2
3
Avatar

Axel Mendoza

--Axel Mendoza--
13263
| 7 8 8
Camaguey, Cuba
--Axel Mendoza--

DevOps - Full stack - Software Architect - Developer - Technology Integrator

I could help you to develop anything and solve complex problems based on technologies, integrations and tricky stuffs mostly in Python with OpenERP/Odoo, Zato, Django and many others frameworks programming languages and technologies.

I offers consulting services to anyone with an unanswered questions or needs for customizations. Think about it, maybe it's better to have an expert to solve your issues and projects than having a full-time employee trying to understand what to do and how

Reach me at aekroft@gmail.com

Axel Mendoza
On 2/12/16, 12:11 PM

Hi @Pascal

Very good question, I didn't ask that for myself. 

The real answer is no because we are in python, in other strongly typed programming lang the answer would be yes.

The only thing that we do when we define a parser is inherit from report_sxw.rml_parse to add our methods and values into the localcontext dict value by reimplementing the __init__ method to add our stuffs but Odoo 8 do not anything of that, it's just using report_sxw.rml_parse to build the self.localcontext dict and to call the set_context method. The new report api jus do this with the wrapper_report_class

# Generate the old style report

wrapped_report = self._wrapped_report_class(cr, uid, '', context=context)

wrapped_report.set_context(objects, data, context['active_ids'])

# Rendering self._template with the wrapped report instance localcontext as

# rendering environment

docargs = dict(wrapped_report.localcontext)

So you can do this:

class report_parser(object):
    def __init__(self, cr, uid, name, context):

self.localcontext = {

'next_seq': 'value',

'select_value': self._function,

}

def set_context(self, objects, data, ids, report_type = None):

self.localcontext['data'] = data

self.localcontext['objects'] = objects



class report_test1_parser(models.AbstractModel):

_name = 'report.parser_test_module.report_test1'

_inherit = 'report.abstract_report'

_template = 'parser_test_module.report_test1'

_wrapped_report_class = report_parser

So no need to inherit form the old api report_sxw.rml_parse

You are really a beast. Thanks.

Pascal Tremblay
on 2/12/16, 12:26 PM

Good questions gets good answers

Axel Mendoza
on 2/12/16, 12:27 PM

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

2 follower(s)

Stats

Asked: 2/12/16, 7:41 AM
Seen: 3352 times
Last updated: 3/1/16, 2:44 AM