35 lines
1.3 KiB
Python
35 lines
1.3 KiB
Python
# -*- coding: utf-8 -*-
|
|
from odoo import models, fields, api
|
|
|
|
class ResPartner(models.Model):
|
|
_inherit = 'res.partner'
|
|
|
|
is_patient = fields.Boolean(string="Es Paciente")
|
|
patient_identifier = fields.Char(string="Identificador de Paciente", copy=False)
|
|
origin = fields.Char(
|
|
string="Origen",
|
|
default='Manual',
|
|
help="Este campo indica el origen del registro del paciente (ej. Manual, Carga Inicial)."
|
|
)
|
|
birthdate_date = fields.Date(string="Fecha de Nacimiento")
|
|
gender = fields.Selection([
|
|
('male', 'Masculino'),
|
|
('female', 'Femenino'),
|
|
('other', 'Otro')
|
|
], string="Género")
|
|
|
|
is_doctor = fields.Boolean(string="Es Médico")
|
|
doctor_license = fields.Char(string="Licencia Médica", copy=False)
|
|
|
|
_sql_constraints = [
|
|
('patient_identifier_unique', 'unique(patient_identifier)', 'El identificador del paciente debe ser único.'),
|
|
('doctor_license_unique', 'unique(doctor_license)', 'La licencia médica debe ser única.')
|
|
]
|
|
|
|
@api.model_create_multi
|
|
def create(self, vals_list):
|
|
for vals in vals_list:
|
|
if vals.get('is_patient') and not vals.get('patient_identifier'):
|
|
vals['patient_identifier'] = self.env['ir.sequence'].next_by_code('res.partner.patient_identifier')
|
|
return super(ResPartner, self).create(vals_list)
|