Hello
Trying to use code to increment a number for my helpdesk module and got this error:
Traceback (most recent call last):
File "/usr/lib/python2.7/dist-packages/openerp/http.py", line 530, in _handle_exception
return super(JsonRequest, self)._handle_exception(exception)
File "/usr/lib/python2.7/dist-packages/openerp/http.py", line 567, in dispatch
result = self._call_function(**self.params)
File "/usr/lib/python2.7/dist-packages/openerp/http.py", line 303, in _call_function
return checked_call(self.db, *args, **kwargs)
File "/usr/lib/python2.7/dist-packages/openerp/service/model.py", line 113, in wrapper
return f(dbname, *args, **kwargs)
File "/usr/lib/python2.7/dist-packages/openerp/http.py", line 300, in checked_call
return self.endpoint(*a, **kw)
File "/usr/lib/python2.7/dist-packages/openerp/http.py", line 796, in __call__
return self.method(*args, **kw)
File "/usr/lib/python2.7/dist-packages/openerp/http.py", line 396, in response_wrap
response = f(*args, **kw)
File "/usr/lib/python2.7/dist-packages/openerp/addons/web/controllers/main.py", line 936, in call_kw
return self._call_kw(model, method, args, kwargs)
File "/usr/lib/python2.7/dist-packages/openerp/addons/web/controllers/main.py", line 928, in _call_kw
return getattr(request.registry.get(model), method)(request.cr, request.uid, *args, **kwargs)
File "/usr/lib/python2.7/dist-packages/openerp/api.py", line 241, in wrapper
return old_api(self, *args, **kwargs)
File "/usr/lib/python2.7/dist-packages/openerp/api.py", line 336, in old_api
result = method(recs, *args, **kwargs)
File "/usr/lib/python2.7/dist-packages/openerp/models.py", line 1325, in default_get
defaults[name] = field.default(self)
File "/usr/lib/python2.7/dist-packages/openerp/fields.py", line 433, in <lambda>
func(recs), recs, validate=False,
File "/usr/lib/python2.7/dist-packages/openerp/fields.py", line 1025, in convert_to_cache
return int(value or 0)
ValueError: invalid literal for int() with base 10: '/'
.py code:
class helpdesk(models.Model):
_name = 'helpdesk.ticket'
name = fields.Char("Subject", size=128)
ticketnumber = fields.Integer("Tkt Num", readonly=True)
def create(self, cr, uid, vals, context=None):
vals['ticketnumber'] = self.pool.get('ir.sequence').get(cr, uid, 'helpdesk.ticket')
return super(helpdesk.ticketnumber, self).create(cr, uid, vals, context=context)
_defaults = {
'ticketnumber': lambda obj, cr, uid, context: '/'
}
XML code:
<data noupdate="1">
<record id="seq__responsible_code_inh1" model="ir.sequence.type">
<field name="name">ticketnumber</field>
<field name="code">helpdesk.ticket</field>
</record>
<record id="seq_cloan_code_inh2" model="ir.sequence">
<field name="name">ticketnumber</field>
<field name="code">helpdesk.ticket</field>
<field name="prefix"></field>
<field name="padding">3</field>
</record>
</data>
When I change Ticketnumber from Integer to a Char I get this error:
return super(helpdesk.ticketnumber, self).create(cr, uid, vals, context=context)
TypeError: must be type, not Char
Any advice here?
New error message after change code to int: Traceback (most recent call last): File "/usr/lib/python2.7/dist-packages/openerp/http.py", line 530, in _handle_exception return super(JsonRequest, self)._handle_exception(exception) File "/usr/lib/python2.7/dist-packages/openerp/http.py", line 567, in dispatch result = self._call_function(**self.params) File "/usr/lib/python2.7/dist-packages/openerp/http.py", line 303, in _call_function return checked_call(self.db, *args, **kwargs) File "/usr/lib/python2.7/dist-packages/openerp/service/model.py", line 113, in wrapper return f(dbname, *args, **kwargs) File "/usr/lib/python2.7/dist-packages/openerp/http.py", line 300, in checked_call return self.endpoint(*a, **kw) File "/usr/lib/python2.7/dist-packages/openerp/http.py", line 796, in __call__ return self.method(*args, **kw) File "/usr/lib/python2.7/dist-packages/openerp/http.py", line 396, in response_wrap response = f(*args, **kw) File "/usr/lib/python2.7/dist-packages/openerp/addons/web/controllers/main.py", line 936, in call_kw return self._call_kw(model, method, args, kwargs) File "/usr/lib/python2.7/dist-packages/openerp/addons/web/controllers/main.py", line 928, in _call_kw return getattr(request.registry.get(model), method)(request.cr, request.uid, *args, **kwargs) File "/usr/lib/python2.7/dist-packages/openerp/api.py", line 241, in wrapper return old_api(self, *args, **kwargs) File "/home/vagrant/addons/helpdesk/helpdesk.py", line 27, in create return super(helpdesk.ticketnumber, self).create(cr, uid, vals, context=context) TypeError: must be type, not Integer