No Description
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

ms_poli.py 948B

123456789101112131415161718192021222324252627282930313233
  1. from odoo import fields, api, models
  2. class ms_poli(models.Model):
  3. _name = "ms.poli"
  4. _description = "Poli"
  5. name = fields.Char('Nama Poli', required=True)
  6. kode = fields.Char('Kode Poli', required=True, copy=False)
  7. _sql_constraints = [
  8. ('unique_kode', 'unique(kode)', 'Kode Poli duplicate, mohon cek kembali !'),
  9. ]
  10. @api.multi
  11. def name_get(self):
  12. result = []
  13. for me in self :
  14. result.append((me.id, "%s - %s" % (me.kode, me.name)))
  15. return result
  16. @api.model
  17. def name_search(self, name, args=None, operator='ilike', limit=100):
  18. args = args or []
  19. if name :
  20. recs = self.search([
  21. '|',
  22. ('kode', operator, name),
  23. ('name', operator, name),
  24. ] + args, limit=limit)
  25. else :
  26. recs = self.search([] + args, limit=limit)
  27. return recs.name_get()