From 55648dada1b9b0ad246ec2998dcdb4f97f6cf0db Mon Sep 17 00:00:00 2001 From: Robin Baumgartner Date: Mon, 24 Nov 2014 14:02:57 +0100 Subject: [PATCH] Use Null constant from python-sql for comparisons issue4143 review13701003 --- product.py | 7 ++++--- purchase.py | 9 +++++---- setup.py | 2 +- stock.py | 4 +++- 4 files changed, 13 insertions(+), 9 deletions(-) diff --git a/product.py b/product.py index 7920f1b2bd..ba85e80971 100644 --- a/product.py +++ b/product.py @@ -1,7 +1,8 @@ #This file is part of Tryton. The COPYRIGHT file at the top level of #this repository contains the full copyright notices and license terms. import datetime -from sql import Literal + +from sql import Literal, Null from sql.aggregate import Count from trytond.model import ModelView, ModelSQL, MatchMixin, fields @@ -212,7 +213,7 @@ class ProductSupplier(ModelSQL, ModelView, MatchMixin): @staticmethod def order_sequence(tables): table, _ = tables[None] - return [table.sequence == None, table.sequence] + return [table.sequence == Null, table.sequence] @staticmethod def default_company(): @@ -316,7 +317,7 @@ class ProductSupplierPrice(ModelSQL, ModelView, MatchMixin): @staticmethod def order_sequence(tables): table, _ = tables[None] - return [table.sequence == None, table.sequence] + return [table.sequence == Null, table.sequence] @staticmethod def default_quantity(): diff --git a/purchase.py b/purchase.py index c324becaca..41a501c3d3 100644 --- a/purchase.py +++ b/purchase.py @@ -3,7 +3,8 @@ import datetime from itertools import chain from decimal import Decimal -from sql import Table, Literal + +from sql import Table, Literal, Null from sql.functions import Overlay, Position from sql.aggregate import Count from sql.operators import Concat @@ -288,8 +289,8 @@ class Purchase(Workflow, ModelSQL, ModelView): purchase_line.id)) ).select(sql_table.id, where=((sql_table.state == 'confirmed') - & ((invoice_line.id != None) - | (move.id != None)))) + & ((invoice_line.id != Null) + | (move.id != Null)))) cursor.execute(*sql_table.update( columns=[sql_table.state], values=['processing'], @@ -1011,7 +1012,7 @@ class PurchaseLine(ModelSQL, ModelView): @staticmethod def order_sequence(tables): table, _ = tables[None] - return [table.sequence == None, table.sequence] + return [table.sequence == Null, table.sequence] @staticmethod def default_type(): diff --git a/setup.py b/setup.py index ac8919cd36..7f4b821d87 100644 --- a/setup.py +++ b/setup.py @@ -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)) diff --git a/stock.py b/stock.py index a74e90d701..a9b52dc97c 100644 --- a/stock.py +++ b/stock.py @@ -1,6 +1,8 @@ #This file is part of Tryton. The COPYRIGHT file at the top level of #this repository contains the full copyright notices and license terms. import datetime + +from sql import Null from sql.operators import Concat from trytond.model import Workflow, ModelView, fields @@ -190,7 +192,7 @@ class Move: cursor.execute(*sql_table.update( columns=[sql_table.origin], values=[Concat('purchase.line,', sql_table.purchase_line)], - where=sql_table.purchase_line != None)) + where=sql_table.purchase_line != Null)) table.drop_column('purchase_line') @classmethod