This question has been flagged
2 Replies
3917 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

Avatar
Discard
Best Answer

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']
Avatar
Discard
Best Answer

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 ! 

Avatar
Discard