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.

0

how to customize a report in openerp8

By
feriel bendimerad
on 5/8/14, 7:12 AM 1,898 views

hello , i'm working on Openerp8 , i have used inheritance to customize the report account invoice like i'v used in openerp7. here is my code:

# -*- coding: utf-8 -*-
#!/usr/bin/env pythons
from openerp.addons.account.report import account_print_invoice
from integerToWords_fr import final_result
import locale 
from openerp.report import report_sxw
import logging
from logging import Logger
logger = logging.getLogger('trainings module')
# create a custom parser inherited from sale order parser:
class new_account_invoice(account_print_invoice.account_invoice):
    '''Custom parser with an additional method
    '''
    def __init__(self, cr, uid, name, context):
        super(new_account_invoice, self).__init__(cr, uid, name, context)
        self.localcontext.update({
            'final_result':final_result,#
            'droit_timbre':self.droit_timbre,# 

        }) 

    def droit_timbre(self,s):
            if s<=20: return 0
            elif s>20  and s<=500 : return 5 
            elif s>500 and s<250000: return round((s/100)+0.49)
            elif s>=250000: return 2500




# remove previous account.report service :
from netsvc import Service
del Service._services['report.account.invoice']

# register the new report service :
report_sxw.report_sxw('report.account.invoice','account.invoice','addons/l10n_dz/report/account_print_invoice_dz.rml',parser=new_account_invoice)

i've got error this error: File "/usr/lib/pymodules/python2.7/openerp/addons/l10n_dz/report/account_print_invoice_dz.py", line 52, in <module> from netsvc import Service ImportError: No module named netsvc

2

Dhinesh - Technical Consultant, Sodexis Inc

--Dhinesh - Technical Consultant, Sodexis Inc--
3577
| 5 4 9
Pondicherry, India
--Dhinesh - Technical Consultant, Sodexis Inc--

Passionate coder in Python/OpenERP. Knows Django/Flask MVC frameworks. Did code in Java, PHP.

Contact me at: dvdhinesh.mail@gmail.com

Dhinesh - Technical Consultant, Sodexis Inc
On 5/8/14, 12:03 PM

Hi, Try this

from openerp import netsvc
del netsvc.Service._services['report.account.invoice']

Instead of this

from netsvc import Service
del Service._services['report.account.invoice']
1
Sylvain Van Hoof
On 10/8/14, 8:39 AM

Hi, 

With the lastest version of Odoo, the class Service doesn't yet existing.

"ParseError: "'module' object has no attribute 'Service'" while parsin"

What is the best solution to fix it ?

Thanks you ! 

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

1 follower(s)

Stats

Asked: 5/8/14, 7:12 AM
Seen: 1898 times
Last updated: 3/16/15, 8:10 AM