Odoo ORM Methods - Part1
HTML-код
- Опубликовано: 31 июл 2024
- #odooorm #ormmethods #odootutorials
Odoo ORM method. ORM method in Odoo. Odoo orm tutorials. ORM API
. Odoo Object Relational Mapping. Odoo create, write, copy, name_get, odoo name search, odoo fields view get, odoo search, odoo browse, odoo search count, odoo copy, odoo unlink etc.
▬ Contents of this video ▬▬▬▬▬▬▬▬▬▬
0:00 - Introduction to Odoo ORM
03:01 - Search
15:59 - Search_count
18:41 - ref
23:10 - browse
26:24 - exists
31:56 - create
38:09 - write
40:55 - copy
43:16 - unlink
Part 2: • Odoo ORM Methods - Pa...
Read: www.odoo.com/documentation/13...
Sorted, Filtered, Mapped: • Odoo ORM: RecordSet Op...
Support us at: ko-fi.com/odoomates
Email : odoomates@gmail.com Наука
03:01 - search
15:59 - search_count
18:41 - ref
23:10 - browse
26:24 - exists
31:56 - create
38:09 - write
40:55 - copy
43:16 - unlink
100% perfect Explenation Sir. Thank you so much.
happy to hear it. Share with friends and support :)
Best explanation so far on RUclips
happy to know that :)
love u man, ur explanations are perfect, thank u very much
Thank for the kind words and the support
Keep it up brother, life saving video
Happy to help
Thank you! Great content.
Welcome :)
Trillion Thanks to you sir.
:)
You are awesome brother...Thanks
:)
Good job 👏,useful tutorial
Glad you liked it
Great thanks champ...
Welcome :)
Nice tutorial, it help people that don't like reading the docs except there are no tutorial
thanks from the heart for all your supports and feedbacks
Keep it up Brother,,
great
Thank you so much 😀
This method os really help ful for me
Glad to hear that
this was really helpful, Brother I want to you to publish videos for the front-end in odoo and how to use javascript
JS: ruclips.net/video/VuUMvzycXQY/видео.html
Website: ruclips.net/video/8uYxWRlxL_U/видео.html
@@OdooMates Thank you brother this is really very help full, and i think you are doinig greate work, I have met several people who are already learning odoo from your channel. so what i can to say " thank you mates"
@@abdelhalimkaddourguettaoui4591 welcome brother for the kind words
Thank you soo much
As per we agreed in the last comment (y). Full video about the Odoo orm
@@OdooMates thank you for your sincere guidance 🙏
Very great
thanks :)
Thank you very much mates
Our pleasure!
For relatively inexperienced OOPS starters ( which I think a major part of aspirant programmers are); there could be better mapping to OOPS concepts. Accordingly in the create record section, the directory declaration is an argument type variable declaration. And the argument value has to correspond to ANY ONE of the data attributes of the PATIENT class/model.
suggesting we need a better orm ?
@@OdooMates Only implied that 'OBJECTS' have to be explained better before you talk about Object Relationship and also underpin the OOPS concept as much as possible
@@sarathexelixir6801 thanks for suggestion
first of all thank you for your videos,
i'm going to forward in odoo developing with your videos step by step.
but in this section , i don't know why odoo orm methods doesn't work properly:
instead of giving the same output just like this videos in search method
it gives me this output:
patients.... hospital.patient(1,)
could you help me please how solve this problem????
the expected output of search orm method is as the same, you will get a recordset, now you can get the values from recordset by calling .field_name
Good job 👍👍
Thanks :)
Great Job guys, Very interesting video. My question is if you need to pass another field value (value from a Many2one field as one of the search criteria)
Code Sample
field1 = fields.Many2one("model1.model1", string="field1", required=False, )
def action_confirm:
for rec in self
patients = self.env['hospital.patient'].search([('gender', '=', 'field1' ])
Thanks
try like this
patients = self.env['hospital.patient'].search([('gender', '=', self.field1.gender ])
@@OdooMates Thanks
@@adeniyio5582 welcome :)
another very useful video. but i think for unlink id =18, you didnt press the confirm button, thats why it wasnt removed. But now im thinking you are making these small mistakes deliberately, so we can notice and learn better :)
;)
thank you, can you please improve the audio quality ? that would help focus more
sorry for the issue in audio quality, we have improved it in the recent videos :)
Thanks
thanks
I am watching your videos. I have a question. Why are you using FOR in your action_confirm function if self represents one record. I tried a similar function with FOR and with no FOR and they both worked. The other question is when self represents one record or more. Thanks
Hi, the case is to avoid the singleton error when you have multiple records, suppose if you need to call, the same action from the action button in the tree view, it will be helpfull.
As a safe side it is always recommended to iterate self over a loop to avoid singleton error
@@OdooMates Hi, thank you for your help
A question!
What method can I get the values of a select-option?
For example in gender it has 3 values, 'Male', 'Female', 'Other'
How can I print these values on the console?
Will this help brother ? env['model_name]._columns['field_name'].selection
@@OdooMates I try to use "request"
request.env['my.model']._columns['field_anme'].selection
But show me an error ):
my.model object has no attribute '_columns'
@@lenninlawliett may i know your version
@@OdooMates I have Odoo 14
@@OdooMates
I found the solution! :D (for Odoo 14)
I have this field in my model:
thank you mates.....
Thank you too!
Thanks for your video but i can't really listen clearly, appreciate if there is any subtitle !
unfortunately we haven't added subtitles yet
Who can we use or condition between more then two statements inside a search method.
please explain it.
for OR add '|' as ['|', ('ttype','!=','many2many'), ('state','!=','manual')]
Thank you my teacher :).
Welcome :)
what is meant by for rec in self and self.env sir?? is rec in self: mandatory??
this is iterating self for a for loop to avoid the singleton error
@@OdooMates Thank you
How can I validate if a record exists using "request"?
Something like this:
record_to_update = request.env ['my.model']. browse (id)
if record_to_update.exist ():
... true
else:
... false
instead of exist(), use exists()
@@OdooMates
only "s"? 0.o
I will try, thanks!
@@lenninlawliett yes
what are the columns in the odoo AccountType master , documentType master and how these are accessed in a code ?
if you activate developer mode and navigate go to Settings -> Technical -> Database Structure -> Models, search for the models and open it, then you can see all the fields/columns in the table/model
how we can group data to male and female patients and male patients in search count.
use read_group method
read_group(domain, fields, groupby, offset=0, limit=None, orderby=False, lazy=True)
Get the list of records in list view grouped by the given groupby fields
Parameters
domain -- list specifying search criteria [['field_name', 'operator', 'value'], ...]
fields (list) -- list of fields present in the list view specified on the object
groupby (list) -- list of groupby descriptions by which the records will be grouped. A groupby description is either a field (then it will be grouped by that field) or a string 'field:groupby_function'. Right now, the only functions supported are 'day', 'week', 'month', 'quarter' or 'year', and they only make sense for date/datetime fields.
offset (int) -- optional number of records to skip
limit (int) -- optional max number of records to return
orderby (list) -- optional order by specification, for overriding the natural sort ordering of the groups, see also search() (supported only for many2one fields currently)
lazy (bool) -- if true, the results are only grouped by the first groupby and the remaining groupbys are put in the __context key. If false, all the groupbys are done in one call.
Returns
list of dictionaries(one dictionary for each record) containing:
the values of fields grouped by the fields in groupby argument
__domain: list of tuples specifying the search criteria
__context: dictionary with argument like groupby
Return type [{'field_name_1': value, ...]
Raises AccessError --
if user has no read rights on the requested object
if user tries to bypass access rules for read on the requested object
Hi! where can I get the Hospital module? Can't find it anywhere. Thanks!
Odoo Apps: apps.odoo.com/apps/modules/12.0/om_hospital/
Github: github.com/odoomates/odooapps/tree/12.0
@@OdooMates Thanks a lot for the answer. Great videos!
@@arturop8074 thanks brother
how i can group data in search_count
you may have to use read_group method
How to update Many2one field using write method?
self.field_name = id_of_record
@@OdooMates thank you sir
@@santoshsalekar6739 welcome
Hi is there any possible for writing orm queries for joins??
Yes
@@OdooMates Plz provide an simple example in comments for left join please
@@palanikumar8023 there is a lot of such examples inside the odoo core itself.
For PSQL Queries: www.postgresqltutorial.com/postgresql-joins/
@@OdooMates yes this is simple SQL query but I already written this...Now the requirement is I have to convert all the SQL queries to odoo orm format like self.env['crm.lead'].search[] like this one...is this possible??
bad audio quality
sorry brother, we are doing our best to improve it