Hi, guys
I'm a beginner of odoo. here has a problem thwarted me.
def _generate(self):
# prefix WL + yymmdd _serial = 'WL' + dt.today().strftime("%y%m%d") # search today's last one data on db obj = self.env['yc.weight'].search([('name', '=like', _serial + "%")], limit=1, order='name DESC') if obj: _next = int(obj[0].name[8:]) + 1 _serial += '%03d' % _next else: _serial += '001' self.name = _serial
throw error: _next = int(obj[0].name[8:]) + 1 TypeError: 'bool' object is not subscriptable
but it works in Terminal
>>> obj[0].name
'WL190305058'
>>> _next = int(obj[0].name[8:]) + 1
>>> _next
59
I know ir.sequence model can solve this problem, but I still want to know how come.
Thanks