Use Null constant from python-sql for comparisons

issue4143
review13701003
This commit is contained in:
Robin Baumgartner committed 2014-11-24 13:58:35 +01:00
1 parent 4599a5990f
commit 63bd7b99f3
6 files changed
+27 -24

No files matched your search

+8 -7
View File
@@ -4,7 +4,8 @@ from decimal import Decimal
import datetime
import operator
from itertools import izip, groupby
from sql import Column, Literal
from sql import Column, Literal, Null
from sql.aggregate import Sum
from sql.conditionals import Coalesce
@@ -70,7 +71,7 @@ class TypeTemplate(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_balance_sheet():
@@ -213,7 +214,7 @@ class Type(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_balance_sheet():
@@ -1973,12 +1974,12 @@ class ThirdPartyBalance(Report):
cursor.execute(*line.join(move, condition=line.move == move.id
).join(account, condition=line.account == account.id
).select(line.party, Sum(line.debit), Sum(line.credit),
where=(line.party != None)
where=(line.party != Null)
& account.active
& account.kind.in_(('payable', 'receivable'))
& (account.company == data['company'])
& ((line.maturity_date <= Date.today())
| (line.maturity_date == None))
| (line.maturity_date == Null))
& line_query & posted_clause,
group_by=line.party,
having=(Sum(line.debit) != 0) | (Sum(line.credit) != 0)))
@@ -2128,10 +2129,10 @@ class AgedBalance(Report):
cursor.execute(*line.join(move, condition=line.move == move.id
).join(account, condition=line.account == account.id
).select(line.party, Sum(line.debit) - Sum(line.credit),
where=(line.party != None)
where=(line.party != Null)
& account.active
& account.kind.in_(kind)
& (line.reconciliation == None)
& (line.reconciliation == Null)
& (account.company == data['company'])
& term_query & line_query,
group_by=line.party,
+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 ModelView, ModelSQL, fields
from trytond.wizard import Wizard, StateTransition
from trytond import backend
@@ -78,7 +80,7 @@ class JournalViewColumn(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_required():
+2 -5
View File
@@ -6,10 +6,7 @@ from itertools import groupby, combinations
from operator import itemgetter
from collections import defaultdict
try:
from sql import Null
except ImportError:
Null = None
from sql import Null
from sql.aggregate import Sum
from sql.conditionals import Coalesce, Case
@@ -1009,7 +1006,7 @@ class Line(ModelSQL, ModelView):
table = self.__table__()
column = Coalesce(Sum(Coalesce(table.debit, 0)
- Coalesce(table.credit, 0)), 0).cast(type_name)
where = ((table.reconciliation == None)
where = ((table.reconciliation == Null)
& (table.party == self.party.id))
cursor.execute(*table.select(column,
where=where
+7 -6
View File
@@ -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.
from decimal import Decimal
from sql import Literal
from sql import Literal, Null
from sql.aggregate import Sum
from sql.conditionals import Coalesce
@@ -99,7 +100,7 @@ class Party:
if name in ('receivable_today', 'payable_today'):
code = name[:-6]
today_query = ((line.maturity_date <= Date.today())
| (line.maturity_date == None))
| (line.maturity_date == Null))
cursor.execute(*line.join(account,
condition=account.id == line.account
@@ -108,7 +109,7 @@ class Party:
where=account.active
& (account.kind == code)
& line.party.in_([p.id for p in parties])
& (line.reconciliation == None)
& (line.reconciliation == Null)
& (account.company == company_id)
& line_query & today_query,
group_by=line.party))
@@ -161,7 +162,7 @@ class Party:
if name in ('receivable_today', 'payable_today'):
code = name[:-6]
today_query = ((line.maturity_date <= Date.today())
| (line.maturity_date == None))
| (line.maturity_date == Null))
line_query, _ = MoveLine.query_get(line)
Operator = fields.SQL_OPERATORS[clause[1]]
@@ -170,8 +171,8 @@ class Party:
).select(line.party,
where=account.active
& (account.kind == code)
& (line.party != None)
& (line.reconciliation == None)
& (line.party != Null)
& (line.reconciliation == Null)
& (account.company == company_id)
& today_query,
group_by=line.party,
+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-dateutil', 'python-sql']
requires = ['python-dateutil', '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))
+6 -4
View File
@@ -2,6 +2,8 @@
#this repository contains the full copyright notices and license terms.
import datetime
from decimal import Decimal
from sql import Null
from sql.aggregate import Sum
from trytond.model import ModelView, ModelSQL, MatchMixin, fields
@@ -419,7 +421,7 @@ class TaxTemplate(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():
@@ -698,7 +700,7 @@ class Tax(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_active():
@@ -1140,7 +1142,7 @@ class TaxRuleLineTemplate(ModelSQL, ModelView):
@staticmethod
def order_sequence(tables):
table, _ = tables[None]
return [table.sequence == None, table.sequence]
return [table.sequence == Null, table.sequence]
def _get_tax_rule_line_value(self, rule_line=None):
'''
@@ -1254,7 +1256,7 @@ class TaxRuleLine(ModelSQL, ModelView, MatchMixin):
@staticmethod
def order_sequence(tables):
table, _ = tables[None]
return [table.sequence == None, table.sequence]
return [table.sequence == Null, table.sequence]
def match(self, pattern):
if 'group' in pattern and not self.group: