Search code examples
pythonxmlodooopenerp-7

inherit hr_timesheet_sheet.sheet, error: module.__init__() takes at most 2 arguments


When trying to inherit hr_timesheet_sheet.sheet in openerp 7, an error appeared:

TypeError : Error when calling the metaclass bases
module.__init__() takes at most 2 arguments (3 given)

After doing some research, some say that the inheritance is screwy, and hr_timesheet_sheet.sheet might be a module not a class. I need your help.

Here is my code:

# -*- coding: utf-8 -*-
from openerp.osv import fields, orm, osv
from datetime import datetime
from datetime import date
from openerp import api
from datetime import datetime, date, timedelta
import dateutil.parser
import datetime

class hr_timesheet_sheet(osv.osv):
_inherit = 'hr_timesheet_sheet.sheet'

_columns = {
    'weekend': fields.integer( 'weekend'),
}
hr_timesheet_sheet()

I did import the right file of my custom module in __init__.py file

import hr_timesheet_sheet

PS. I'm new with openerp and python


Solution

  • I don't know exactly how, but this worked for me:

    class hr_timesheet_sheet():
    _inherit = 'hr_timesheet_sheet.sheet'
    _columns = {
       'weekend': fields.integer( 'weekend'),
    }
    hr_timesheet_sheet()
    

    and you should go to openerp.py, put this line:

    'depends': [ 'hr','hr_timesheet_sheet'],
    

    you can keep your class as it is class hr_timesheet_sheet(osv.osv):