diff --git a/trytond/ir/sequence.py b/trytond/ir/sequence.py index 28c28073ac..f3935cf443 100644 --- a/trytond/ir/sequence.py +++ b/trytond/ir/sequence.py @@ -20,7 +20,10 @@ class Sequence(OSV): _name = 'ir.sequence' _description = __doc__ name = fields.Char('Sequence Name', required=True, translate=True) - code = fields.Selection('code_get', 'Sequence Type', required=True) + code = fields.Selection('code_get', 'Sequence Type', required=True, + states={ + 'readonly': "context.get('code')", + }) active = fields.Boolean('Active') prefix = fields.Char('Prefix') suffix = fields.Char('Suffix') @@ -50,6 +53,11 @@ class Sequence(OSV): def default_padding(self, cursor, user, context=None): return 0 + def default_code(self, cursor, user, context=None): + if context is None: + context = {} + return context.get('code', False) + def code_get(self, cursor, user, context=None): sequence_type_obj = self.pool.get('ir.sequence.type') sequence_type_ids = sequence_type_obj.search(cursor, user, [], diff --git a/trytond/osv/orm.py b/trytond/osv/orm.py index 5097561394..2ea2d3aa86 100644 --- a/trytond/osv/orm.py +++ b/trytond/osv/orm.py @@ -2683,14 +2683,16 @@ class ORM(object): _symbol_set[0]] * len(arg[2])))) if todel: if arg[1] == 'in': - qu1[-1] = '(' + qu1[-1] + ' or ' \ - + arg[0] + ' is null)' + qu1[-1] = '(' + qu1[-1] + ' OR ' \ + '%s.%s IS NULL)' % \ + (table._table, arg[0]) else: - qu1[-1] = '(' + qu1[-1] + ' or ' \ - + arg[0] + ' is not null)' + qu1[-1] = '(' + qu1[-1] + ' OR ' \ + '%s.%s IS NOT NULL)' % \ + (table._table, arg[0]) qu2 += arg[2] elif todel: - qu1.append('(' + arg[0] + ' IS NULL)') + qu1.append('(%s.%s IS NULL)' % (table._table, arg[0])) else: if arg[1] == 'in': qu1.append(' false')