-
To override the create method we have to add a method named
createlike below. It will override the description field if it is empty.@api.model def create(self, vals): if not vals['description']: vals['description'] = "Enter the description here" res = super(HospitalAppointment, self).create(vals) return res
-
First we have to create a
datadirectory and create a file namedappointment_seq.xml. Insert the below code for creating a sequence.<record id="seq_appointment" model="ir.sequence"> <field name="name">Appointment Sequence</field> <field name="code">kmhospital.appointment</field> <field name="prefix">AS</field> <field name="padding">5</field> <field name="company_id" eval="False"/> </record>
-
Check
Settings > Technical > Sequencesif the sequence is created or not. -
Add a field
nameto theappointment.pyfile.name = fields.Char(string='Appointment Reference', required=True, copy=False, readonly=True, default=lambda self: _('New'))
-
Add this code to the
createmethod.if vals.get('name', _('New')) == _('New'): vals['name'] = self.env['ir.sequence'].next_by_code('kmhospital.appointment') or _('New')
-
Add the code in the
appointment_view.xmlfile inside thesheettag.<div class="oe_title"> <h1> <field name="name"/> </h1> </div>

