Saturday, April 25, 2020

orm methods in odoo

ODOO

ORM

 
ORM Methods in odoo :
  • ORM is stands for Object Relational Mapping 
  • Used to convert data between incompatible type system
  • Odoo modeling is based on "objects" but it's data is stored in a classical relational database 

žsearch()

 
           Use to search for records in object
ž           Input > search domain
ž           Output > list of ids
ž           Employee_ids = self.env[‘hr.employee’].search([‘age’,’=‘,65])

browse()  



žUse to get record set
žInput > list of ids
žOutput > record set
žfaculty =  self.pool.get('op.faculty').browse(self.cr, self.uid, faculty_id)

 create()


ž           Used to create new records in object
ž           Input > field’s values
ž           Output > create new reord in object
ž           Employee_id = self.env[‘hr.employee’]
ž           Employee_ids.create({‘name’:Juhn,’age’:28,’gender’:’male’})

write()


ž          Used to write our update values of records
ž          Input > field’s values
ž          Output > write these values to all records in it’s record set
ž          Employee_id = self.env[‘hr.employee’].search([(‘id’,’=’,1)])
ž          Employee_ids.write({‘name’:’mark’,’age’:38})
            Write () with relational fields
            0, 0, { values }) link to a new record that needs to be created with the given values dictionary
ž(1, ID, { values }) update the linked record with id = ID (write values on it)
ž(2, ID) remove and delete the linked record with id = ID
ž(3, ID) cut the link to the linked record with id = ID
ž(4, ID) link to existing record with id = ID (adds a relationship)
ž(5) unlink all (like using (3,ID) for all linked records)
ž(6, 0, [IDs]) replace the list of linked IDs
  

exists()


žReturns a new recordset containing only the records which exist in the database
žif not record.exists(): raise Exception("The record has been deleted")

ensure_one ()

           checks that the recordset is a singleton
self.ensure_one()

PREVIOUS STEP                    NEXT STEP

No comments:

Post a Comment

Odoo Invoice Qr code issues

There are two main issues must of us facing with the QR code in Odoo invoice & these issues are 1/ QR code displayed as broken image w...