Created
April 28, 2020 02:00
-
-
Save oriewancu/24d0f8f7a06fec1c46be5370dc0dde43 to your computer and use it in GitHub Desktop.
sequence
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from odoo import models, fields, api | |
| class RumahsakitPasien(models.Model): | |
| _name = 'rumahsakit.pasien' | |
| _description = 'Master Pasien' | |
| _rec_name = 'nama' | |
| nama = fields.Char(string='Nama', required=True) | |
| umur = fields.Integer(string='Umur') | |
| keterangan = fields.Text(string='Catatan') | |
| foto = fields.Binary(string='Foto', attachment=True) | |
| gender = fields.Selection([ | |
| ('laki', 'Laki-laki'), | |
| ('perempuan', 'Perempuan') | |
| ], string='Jenis Kelamin', default='laki') | |
| name_seq = fields.Char(string='Reference', required=True, copy=False, readonly=True, | |
| index=True, default=lambda self: ('New')) | |
| @api.model | |
| def create(self, vals): | |
| if vals.get('name_seq', ('New')) == ('New'): | |
| vals['name_seq'] = self.env['ir.sequence'].next_by_code('rumahsakit.pasien.sequence') or ('New') | |
| return super(RumahsakitPasien, self).create(vals) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment