Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

2

How can i replace the Report sale_order.rml with a custom version?

By
herbert6453
on 3/8/13, 10:39 AM 2,239 views

My Modul for OpenERP 6.1 do not work with OpenERP 7.0 .

I believe the problem is the declaration 'report_name': 'sale.order' in the print_quotation method. (Report name instead of report id)

I used for my report the same name, as quick fix. This works, but i have problems with the translation (my po file is not used).

I want replace the "print" button with my own version and call my own "print_quotation_new" method, but i can not evaluate the consequences (for workflows or whatever).

1
Sajad KK
On 2/16/14, 11:46 PM

You can override the default report like below

1) Create a xml file in your module custom_report.xml with following content

<?xml version="1.0" encoding="utf-8"?>
<openerp>
    <data>
        <report auto="False" id="sale.report_sale_order" model="sale.order" name="sale.order"
                rml="your_module/report/sale_order.rml" string="New Quotation / Order"
                usage="default"/>
    </data>
</openerp>

2) Copy your custom rml file to your_module/report/sale_order.rml

3) Create your custom parser your_module/report/sale_order.py

import time
from sale.report import sale_order
from openerp.report import report_sxw

class order(sale_order.order):
    def __init__(self, cr, uid, name, context):
        super(order, self).__init__(cr, uid, name, context=context)

from netsvc import Service
del Service._services['report.sale.order']

report_sxw.report_sxw('report.sale.order', 'sale.order', 'your_module/report/sale_order.rml', parser=order, header='external')

4) create your_module/report/__init__.py

import sale_order

5)update your __openerp__.py file

'data': ['custom_report.xml',]

6) Restart your server and update your module

I have already wondered what is the right way to replace reports... Does this mean in v6, report name has to be changed and in v7, not name but id?

NSC
on 2/18/14, 3:29 AM

Report name should be same and the id should be changed to 'module.id' format.

Sajad KK
on 2/18/14, 10:50 PM

Okay, thank you for that information. Very often, I read that name should be changed, but when doing like that, my module could not be fully uninstalled again. Maybe, this depends on OpenERP version. What I still do not understand is the think with the id changed to 'module.id' - is it really important that id is called like that? I thought id only has to be unique. What if you override same report twice? Then you need another id, anyway...

NSC
on 2/20/14, 3:45 AM

report name should be same and the id should be changed :-)

Sajad KK
on 2/26/14, 7:10 AM

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

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

Question tools

0 follower(s)

Stats

Asked: 3/8/13, 10:39 AM
Seen: 2239 times
Last updated: 3/16/15, 8:10 AM