Use Null constant from python-sql for comparisons

issue4143
review13701003
This commit is contained in:
Robin Baumgartner
2014-11-24 14:03:52 +01:00
parent 35e5a4a7a9
commit 486006e8ff
4 changed files with 19 additions and 15 deletions
+3 -1
View File
@@ -1,5 +1,7 @@
#This file is part of Tryton. The COPYRIGHT file at the top level
#of this repository contains the full copyright notices and license terms.
from sql import Null
from trytond.model import Workflow, ModelView, ModelSQL, fields
from trytond.pyson import Not, Equal, Eval, Or, Bool
from trytond import backend
@@ -273,7 +275,7 @@ class InventoryLine(ModelSQL, ModelView):
# Migration from 3.0: use Move origin
if table.column_exist('move'):
cursor.execute(*sql_table.select(sql_table.id, sql_table.move,
where=sql_table.move != None))
where=sql_table.move != Null))
for line_id, move_id in cursor.fetchall():
cursor.execute(*move_table.update(
columns=[move_table.origin],
+12 -11
View File
@@ -4,7 +4,8 @@ import datetime
import operator
from decimal import Decimal
from functools import partial
from sql import Literal, Union, Column
from sql import Literal, Union, Column, Null
from sql.aggregate import Sum
from sql.conditionals import Coalesce
from sql.operators import Concat
@@ -345,7 +346,7 @@ class Move(Workflow, ModelSQL, ModelView):
columns=[sql_table.shipment],
values=[Concat(model + ',',
Column(sql_table, column))],
where=Column(sql_table, column) != None))
where=Column(sql_table, column) != Null))
table.drop_column(column)
# Add index on create_date
@@ -889,7 +890,7 @@ class Move(Workflow, ModelSQL, ModelView):
context.get('stock_assign') and 'assigned' or 'done'])
& (
(
(move.effective_date == None)
(move.effective_date == Null)
& (move.planned_date <= context['stock_date_end'])
)
| (move.effective_date <= context['stock_date_end'])
@@ -905,7 +906,7 @@ class Move(Workflow, ModelSQL, ModelView):
or 'done'])
& (
(
(move.effective_date == None)
(move.effective_date == Null)
& (move.planned_date <= today)
)
| (move.effective_date <= today)
@@ -914,7 +915,7 @@ class Move(Workflow, ModelSQL, ModelView):
| (move.state.in_(['done', 'assigned', 'draft'])
& (
(
(move.effective_date == None)
(move.effective_date == Null)
& (Coalesce(move.planned_date, datetime.date.max)
<= context['stock_date_end'])
& (Coalesce(move.planned_date, datetime.date.max)
@@ -934,11 +935,11 @@ class Move(Workflow, ModelSQL, ModelView):
move.state.in_(['done', 'assigned', 'draft'])
& (
(
(move.effective_date == None)
(move.effective_date == Null)
& (
(move.planned_date >=
context['stock_date_start'])
| (move.planned_date == None)
| (move.planned_date == Null)
)
)
| (move.effective_date >= context['stock_date_start'])
@@ -950,10 +951,10 @@ class Move(Workflow, ModelSQL, ModelView):
move.state.in_(['done', 'assigned', 'draft'])
& (
(
(move.effective_date == None)
(move.effective_date == Null)
& (
(move.planned_date >= today)
| (move.planned_date == None)
| (move.planned_date == Null)
)
)
| (move.effective_date >= today)
@@ -965,14 +966,14 @@ class Move(Workflow, ModelSQL, ModelView):
or 'done'])
& (
(
(move.effective_date == None)
(move.effective_date == Null)
& (
(
(move.planned_date >=
context['stock_date_start'])
& (move.planned_date < today)
)
| (move.planned_date == None)
| (move.planned_date == Null)
)
)
| (
+3 -2
View File
@@ -2,7 +2,8 @@
#this repository contains the full copyright notices and license terms.
import datetime
from decimal import Decimal
from sql import Literal
from sql import Literal, Null
from sql.aggregate import Max
from sql.functions import Now
from sql.conditionals import Coalesce
@@ -261,7 +262,7 @@ class ProductQuantitiesByWarehouse(ModelSQL, ModelView):
where=(move.product == product_id)
& (move.from_location.in_(warehouse_query)
| move.to_location.in_(warehouse_query))
& (Coalesce(move.effective_date, move.planned_date) != None),
& (Coalesce(move.effective_date, move.planned_date) != Null),
group_by=(date_column, move.product))
@classmethod
+1 -1
View File
@@ -41,7 +41,7 @@ if minor_version % 2:
'hg+http://hg.tryton.org/modules/%s#egg=%s-%s' % (
name[8:], name, version))
requires = ['python-sql']
requires = ['python-sql >= 0.4']
for dep in info.get('depends', []):
if not re.match(r'(ir|res|webdav)(\W|$)', dep):
requires.append(get_require_version('trytond_%s' % dep))