欢迎!
分享和讨论最佳内容和新营销理念,打造专业形象,共同成为更好的营销人员。
In odoo development, self.env.search is used very frequently
This question has been flagged
For beginners, getting started with the Python language is relatively simple because it has many built-in library functions, methods, and modules that can be directly called.
In many ERP systems, the languages chosen by technical engineers during development may vary; the development language used by Odoo is Python. Developers who have worked with Python know that self.env.search is frequently used in Odoo development.
Below is a brief explanation of self and self.env.search usage.
self represents an instance of a class, not the class itself;
Example:
class Test:
def prt(self):
print(self)
print(self.__class__)
t = Test()
t.prt()
The output is:
Example of self.env.search usage:
modle_list = self.env['model'].search( ['&', ('field1', '=', None), ('field2', '!=', None), '&', ('field3', '>=', self.start_datetime), ('field3', '= self.start_datetime&field3