summaryrefslogtreecommitdiff
path: root/addons/mrp/__init__.py
diff options
context:
space:
mode:
authorRichard Mathot <rim@odoo.com>2020-09-16 13:35:02 +0000
committerRichard Mathot <rim@odoo.com>2020-09-23 11:48:29 +0000
commit68b8f1eae653d454538c1552c2553a7d7f06185e (patch)
tree8524b14550b73148a04544af60805e877d2775dd /addons/mrp/__init__.py
parent137bc1098dc66f67eda181d0062327dd570ead01 (diff)
[FIX] mrp: more Voodoo magic
It appears that if you update a record more than once in the same PostgreSQL transaction, PostgreSQL is going to re-check all the constraints on the table. ** THIS IS THE PART WHERE THE BLACK MAGIC HAPPENS ** We combine the setting of the default value of stock.move.unit_factor in the same UPDATE query to avoid the constraint re-check; it saves approximately 60% of the SQL running time in my case. ** ... AND NOW YOU CAN SAY: WHAT THE F...?! ** Thanks to @rco-odoo for the tip; he knows it from the wise @nseinlet. X-original-commit: 8e47e2f605309c8ed0d5509f7bb070528d8f32c4
Diffstat (limited to 'addons/mrp/__init__.py')
-rw-r--r--addons/mrp/__init__.py4
1 files changed, 1 insertions, 3 deletions
diff --git a/addons/mrp/__init__.py b/addons/mrp/__init__.py
index db4bea45d37..01c44c4b198 100644
--- a/addons/mrp/__init__.py
+++ b/addons/mrp/__init__.py
@@ -16,9 +16,7 @@ def _pre_init_mrp(cr):
"""
cr.execute("""ALTER TABLE "stock_move" ADD COLUMN "is_done" bool;""")
cr.execute("""UPDATE stock_move
- SET is_done=TRUE
- WHERE STATE='done'
- OR STATE='cancel';""")
+ SET is_done=COALESCE(state in ('done', 'cancel'), FALSE);""")
def _create_warehouse_data(cr, registry):
""" This hook is used to add a default manufacture_pull_id, manufacture