1
votes

this my class in odoo

class medical_procedure_base(models.Model):
   _name = 'health_administrator.medical_procedure_base'
   _description = 'Medical Procedure'

   name = fields.Char(string='Libellé', required=True)
   code = fields.Char(string='Code', required=True)
   key_letter = fields.Many2one('health_administrator.key_letter', required=True, string="Lettre clé")
   medical_procedure_cat_id = fields.Many2one('health_administrator.medical_procedure_category', required=True, string="Catégorie de l'acte")
   amount = fields.Integer(string="Valeur lettre clé", required=True, default=0)

_order = 'code asc'

What I want, is when i clicked on Save Button from Odoo make a search this model to get all 'Medical Procedure' that have the same key_letter id and medical_procedure_cat_id id in that model and do the odoo create or write method.

Thanks

1
and what you want to do with the result?!!!Charif DZ
Hi @Cherif, with the result i want to use the create method of odoo to insert it in the table also use the write method to update it. ThankMarcel Brou

1 Answers

0
votes

Call super for both create and write function.

Create

@api.model
def create(self,vals):
    #your code
    return super(your_class_name,self).create(vals)

Write

@api.model
def write(self,vals):
    #your code
    return super(your_class_name,self).write(vals)

NB:Create is called when the record is created and write is called when the record is edited.