How to use name_get in odoo 14
Good day, Am trying to use name_get function but it is giving me Internal Server Error Below is my code
class DrugsList(models.Model):
_name = 'hms.drugs.list'
_rec_name = 'drug_name'
name = fields.Char(string='DoC Drug Identifier', default='/', help='Identifier provided by DOC.', copy=True, tracking=True)
drug_name = fields.Char(tracking=True)
default_code = fields.Char(string='Nappi Code', required=True)
@api.multi
def name_get(self):
res = []
for rec in self:
res.append((rec.id, "%s, %s" % (rec.default_code, rec.drug_name)))
return res
@api.model
def create(self, values):
if values.get('name','/')=='/':
values['name'] = self.env['ir.sequence'].next_by_code('hms.drugs.list') or ''
return super(DrugsList, self).create(values)
Solution 1:
The @api.multi decorator is no longer available. You must remove it.
You should see the following error message in the server log:
AttributeError: module 'odoo.api' has no attribute 'multi'
You can check an example in sale module without the multi
decorator or another in account using the depends
decorator.