_inherit = 'res.partner'
staff_code = fields.Char(compute='_random_code', string='Code nhân viên', index=True)
@api.multi
def _random_code(self):
if not self.staff_code:
chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'
code = ''.join(random.SystemRandom().choice(chars) for i in xrange(8))
full_code = 'NV-' + code
self.staff_code = full_code
If dont use "store=True" staff_code change continuously when view user infomation.
If use "store=True", i can't install module.
Many thank!