Skip to Content
Menu
This question has been flagged
1 Reply
4623 Views

How can I fix the following error?I found this error when I migrated module from v10 to v11.

Here is My code in .py file:

@api.model
    def create(self, vals):
        date_start = self.env['ir.values'].get_default('res.config.settings', 'so_expiration_date_start')
        if not date_start:
            if 'validity_date' in vals:
                if vals.get('validity_date'):
                    pass
                else:
                    date_no = self.env['ir.values'].get_default('res.config.settings', 'so_expiration_date_no')
                    date_today = fields.Date.today()
                    date_object = datetime.strptime(date_today, '%Y-%m-%d')
                    if not date_no:
                        pass
                    else:
                        v_date = date_object + timedelta(days=date_no)
                        vals['validity_date'] = v_date

        return super(SaleOrder, self).create(vals)

The error log is

2018-05-16 10:00:28,331 15743 ERROR odoo11comTestData odoo.http: Exception during JSON request handling.
Traceback (most recent call last):
  File "/home/sudarly/odoo11com/odoo11com-server/odoo/http.py", line 647, in _handle_exception
    return super(JsonRequest, self)._handle_exception(exception)
  File "/home/sudarly/odoo11com/odoo11com-server/odoo/http.py", line 307, in _handle_exception
    raise pycompat.reraise(type(exception), exception, sys.exc_info()[2])
  File "/home/sudarly/odoo11com/odoo11com-server/odoo/tools/pycompat.py", line 87, in reraise
    raise value
  File "/home/sudarly/odoo11com/odoo11com-server/odoo/http.py", line 689, in dispatch
    result = self._call_function(**self.params)
  File "/home/sudarly/odoo11com/odoo11com-server/odoo/http.py", line 339, in _call_function
    return checked_call(self.db, *args, **kwargs)
  File "/home/sudarly/odoo11com/odoo11com-server/odoo/service/model.py", line 97, in wrapper
    return f(dbname, *args, **kwargs)
  File "/home/sudarly/odoo11com/odoo11com-server/odoo/http.py", line 332, in checked_call
    result = self.endpoint(*a, **kw)
  File "/home/sudarly/odoo11com/odoo11com-server/odoo/http.py", line 933, in __call__
    return self.method(*args, **kw)
  File "/home/sudarly/odoo11com/odoo11com-server/odoo/http.py", line 512, in response_wrap
    response = f(*args, **kw)
  File "/home/sudarly/odoo11com/odoo11com-server/addons/web/controllers/main.py", line 934, in call_button
    action = self._call_kw(model, method, args, {})
  File "/home/sudarly/odoo11com/odoo11com-server/addons/web/controllers/main.py", line 922, in _call_kw
    return call_kw(request.env[model], method, args, kwargs)
  File "/home/sudarly/odoo11com/odoo11com-server/odoo/api.py", line 689, in call_kw
    return call_kw_multi(method, model, args, kwargs)
  File "/home/sudarly/odoo11com/odoo11com-server/odoo/api.py", line 680, in call_kw_multi
    result = method(recs, *args, **kwargs)
  File "/home/sudarly/odoo11com/odoo11com-server/addons/quotation_handler/models/sale.py", line 114, in make_revision
    new_so_copy = rec.copy(default=vals)
  File "/home/sudarly/odoo11com/odoo11com-server/odoo/models.py", line 3876, in copy
    new = self.with_context(lang=None).create(vals)
  File "/home/sudarly/odoo11com/odoo11com-server/addons/quotation_handler/models/sale.py", line 56, in create
    date_start = self.env['ir.values'].get_default('res.config.settings', 'so_expiration_date_start')
  File "/home/sudarly/odoo11com/odoo11com-server/odoo/api.py", line 760, in __getitem__
    return self.registry[model_name]._browse((), self)
  File "/home/sudarly/odoo11com/odoo11com-server/odoo/modules/registry.py", line 181, in __getitem__
    return self.models[model_name]
KeyError: 'ir.values'

Avatar
Discard
Best Answer

This seems like a similiar error. Have you checked it out already?

IR values in Odoo 11

Avatar
Discard
Related Posts Replies Views Activity
2
Jul 24
939
1
Jun 24
3560
1
Oct 23
8582
1
Oct 23
97
1
Aug 23
2192