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

Error while installing module (odoo/openerp/models.py", line 645, in _build_model model.__init__(pool, cr))

By
Skif
on 6/3/16, 4:40 AM 366 views

Hi all.

I recived error when install module to odoo8:

Traceback (most recent call last):

File "/home/skif/odoo/openerp/http.py", line 540, in _handle_exception

      return super(JsonRequest, self)._handle_exception(exception)

File "/home/skif/odoo/openerp/http.py", line 577, in dispatch

      result = self._call_function(**self.params)

File "/home/skif/odoo/openerp/http.py", line 313, in _call_function

      return checked_call(self.db, *args, **kwargs)

File "/home/skif/odoo/openerp/service/model.py", line 118, in wrapper

      return f(dbname, *args, **kwargs)

File "/home/skif/odoo/openerp/http.py", line 310, in checked_call

      return self.endpoint(*a, **kw)

File "/home/skif/odoo/openerp/http.py", line 806, in __call__

      return self.method(*args, **kw)

File "/home/skif/odoo/openerp/http.py", line 406, in response_wrap

      response = f(*args, **kw)

File "/home/skif/odoo/addons/web/controllers/main.py", line 948, in call_button

      action = self._call_kw(model, method, args, {})

File "/home/skif/odoo/addons/web/controllers/main.py", line 936, in _call_kw

      return getattr(request.registry.get(model), method)(request.cr, request.uid, *args, **kwargs)

File "/home/skif/odoo/openerp/api.py", line 268, in wrapper

      return old_api(self, *args, **kwargs)

File "/home/skif/odoo/openerp/addons/base/module/module.py", line 447, in button_immediate_install

      return self._button_immediate_function(cr, uid, ids, self.button_install, context=context)

File "/home/skif/odoo/openerp/api.py", line 268, in wrapper

      return old_api(self, *args, **kwargs)

File "/home/skif/odoo/openerp/addons/base/module/module.py", line 495, in _button_immediate_function

      registry = openerp.modules.registry.RegistryManager.new(cr.dbname, update_module=True)

File "/home/skif/odoo/openerp/modules/registry.py", line 370, in new

      openerp.modules.load_modules(registry._db, force_demo, status, update_module)

File "/home/skif/odoo/openerp/modules/loading.py", line 355, in load_modules

      loaded_modules, update_module)

File "/home/skif/odoo/openerp/modules/loading.py", line 255, in load_marked_modules

      loaded, processed = load_module_graph(cr, graph, progressdict, report=report, skip_modules=loaded_modules,     perform_checks=perform_checks)

File "/home/skif/odoo/openerp/modules/loading.py", line 152, in load_module_graph

      models = registry.load(cr, package)

File "/home/skif/odoo/openerp/modules/registry.py", line 163, in load

      model = cls._build_model(self, cr)

File "/home/skif/odoo/openerp/models.py", line 645, in _build_model

      model.__init__(pool, cr)

TypeError: __init__() takes exactly 2 arguments (3 given)


I removed all code from my project and tried install clean module. I received similar error. Now my project is as follows

[controllers.py]

# -*- coding: utf-8 -*-

from openerp import http

import werkzeug

from openerp.http import request

#import os

#from models import SessionVisitor, SessionFirstVisit

class WebCalc(http.Controller):

      @http.route(['/webcalc/remoteaddr/'], type='json', auth='public', website=True)

      def return_map(self):

            '''For JSON you need restart odoo with - u module_name after all modify'''

            remoteAddr = request.httprequest.environ['REMOTE_ADDR']

            return {'remoteAddr': remoteAddr}


      @http.route(['/web_calc/register_session'], type='json', auth='public', website=True)

      def register_session(self, prevouseURL, currentURL):

            '''For JSON you need restart odoo with - u module_name after all modify'''

            return {'remoteAddr': '192.168.1.1', 'sessionID': 23, 'sessionPing': 20, 'sessionTimout': 10}


      @http.route(['/web_calc/check_session'], type='json', auth='public', website=True)

      def check_session(self, sessionID, prevouseURL, currentURL):

            '''For JSON you need restart odoo with - u module_name after all modify'''

            #remoteAddr = request.httprequest.environ['REMOTE_ADDR']

            return {'remoteAddr': '192.12.122.34'}


[models.py]

# -*- coding: utf-8 -*-

from datetime import timedelta

from openerp import models, fields, api

import datetime

# class web_calc(models.Model):

# _name = 'web_calc.web_calc'

# name = fields.Char()

class SessionVisitor(models.Model):

      _name = 'web_calc.session_visitor'

      clientAddr = fields.Char(string="Client_IP", required=True)

      dateVisit = fields.Date(default=fields.Date.today)

      dateLastCheck = fields.Date(default=fields.Date.today)


      def __init__(self, remoteAddr):

            self.clientAddr = remoteAddr

            self.dateVisit = datetime.now

            self.dateLastCheck = datetime.now

            def setDateLastVisit(self, currentDate):

            self.dateLastCheck = currentDate


Every time when I try to install the module, I get the similar error.

What do I wrong?

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: 6/3/16, 4:40 AM
Seen: 366 times
Last updated: 6/3/16, 6:00 AM