From 9920f20e4c7753bc17bea71dea3a90f7de687196 Mon Sep 17 00:00:00 2001 From: Raphael Collet Date: Wed, 14 Aug 2019 07:35:49 +0000 Subject: [IMP] models: ORM speedup This branch is the combination of several optimizations in the ORM: * store field values once in the cache: the cache reflects more faithfully the database, only fields that explicitly depend on the context have an extra indirection in the cache; * delay recomputations by default: use method `recompute` to explicitly flush out pending recomputations; * delay updates in method `write`: updates are stored in a data structure that can be flushed efficiently to the database with method `flush` (which also flush out recomputations); * make method `modified` take advantage of inverse fields to inverse dependencies; * filter records by evaluating a domain on records in Python; * a computed field with `readonly=False` behaves like a normal field with an onchange method; * computed fields are computed in superuser mode by default. Work done by Toufik Ben Jaa, Raphael Collet, Denis Ledoux and Fabien Pinckaers. closes odoo/odoo#35659 Signed-off-by: Denis Ledoux --- odoo/tools/sql.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'odoo/tools/sql.py') diff --git a/odoo/tools/sql.py b/odoo/tools/sql.py index 2a0594b7d34..a805202a019 100644 --- a/odoo/tools/sql.py +++ b/odoo/tools/sql.py @@ -74,7 +74,8 @@ def column_exists(cr, tablename, columnname): def create_column(cr, tablename, columnname, columntype, comment=None): """ Create a column with the given type. """ - cr.execute('ALTER TABLE "{}" ADD COLUMN "{}" {}'.format(tablename, columnname, columntype)) + coldefault = (columntype.upper()=='BOOLEAN') and 'DEFAULT false' or '' + cr.execute('ALTER TABLE "{}" ADD COLUMN "{}" {} {}'.format(tablename, columnname, columntype, coldefault)) if comment: cr.execute('COMMENT ON COLUMN "{}"."{}" IS %s'.format(tablename, columnname), (comment,)) _schema.debug("Table %r: added column %r of type %s", tablename, columnname, columntype) -- cgit v1.2.3