File tree Expand file tree Collapse file tree 2 files changed +21
-7
lines changed
content/developer/reference/backend Expand file tree Collapse file tree 2 files changed +21
-7
lines changed Original file line number Diff line number Diff line change @@ -726,6 +726,13 @@ joins) or for performance reasons::
726726 Please make sure your queries are sanitized when using user input and prefer using
727727 ORM utilities if you don't really need to use SQL queries.
728728
729+ The recommended way to build SQL queries is to use the wrapper object
730+
731+ .. autoclass :: odoo.tools.SQL
732+
733+ .. automethod :: SQL.join
734+ .. automethod :: SQL.identifier
735+
729736One important thing to know about models is that they don't necessarily perform
730737database updates right away. Indeed, for performance reasons, the framework
731738delays the recomputation of fields after modifying records. And some database
@@ -740,7 +747,7 @@ called *flushing* and performs the expected database updates.
740747 # make sure that 'partner_id' is up-to-date in database
741748 self .env[' model' ].flush_model([' partner_id' ])
742749
743- self .env.cr.execute(" SELECT id FROM model WHERE partner_id IN %s " , [ ids] )
750+ self .env.cr.execute(SQL( " SELECT id FROM model WHERE partner_id IN %s " , ids) )
744751 ids = [row[0 ] for row in self .env.cr.fetchall()]
745752
746753 Before every SQL query, one has to flush the data needed for that query. There
Original file line number Diff line number Diff line change 44Changelog
55=========
66
7+ Odoo version 17.0
8+ =================
9+
10+ - Introduce an :class: `~odoo.tools.SQL ` wrapper object to make SQL composition
11+ easier and safer with respect to SQL injections. Methods of the ORM now use it
12+ internally. Introduced by `#134677 <https://github.com/odoo/odoo/pull/134677 >`_.
13+
714Odoo Online version 16.4
815========================
916
10- - ` odoo.models.Model.name_get ` has been deprecated with
17+ - Method :meth: ` ~ odoo.models.Model.name_get ` has been deprecated with
1118 `#122085 <https://github.com/odoo/odoo/pull/122085 >`_.
12- Read `display_name ` instead.
19+ Read field `display_name ` instead.
1320
1421Odoo Online version 16.3
1522========================
1623
17- - ` odoo.models.Model._read_group ` has a new signature with
24+ - Method :meth: ` ~ odoo.models.Model._read_group ` has a new signature with
1825 `#110737 <https://github.com/odoo/odoo/pull/110737 >`_
1926
2027Odoo Online version 16.2
2128========================
2229
2330- Refactor the implementation of searching and reading methods to be able to
2431 combine both in a minimal number of SQL queries. We introduce two new methods
25- ` odoo.models.Model.search_fetch ` and ` odoo.models.Model.fetch ` that take
26- advantage of the combination. More details can be found on the pull request
27- `#112126 <https://github.com/odoo/odoo/pull/112126 >`_.
32+ :meth: ` ~ odoo.models.Model.search_fetch ` and :meth: ` ~ odoo.models.Model.fetch `
33+ that take advantage of the combination. More details can be found on the pull
34+ request `#112126 <https://github.com/odoo/odoo/pull/112126 >`_.
2835
2936Odoo version 16.0
3037=================
You can’t perform that action at this time.
0 commit comments