Hi,

I'm trying to set a domain in a M2O field depending on the value of a 
functional field that is a numeric field this way [1]. But, depending how I 
define the ZERO constant, I get different tracebacks [2] and [3]. Could 
somebody tell me what I'm doing wrong?

Thanks,

[1]
        domain=[
            If(
                Or(
                    And(
                        Eval('type') == 'out',
                        Greater(Eval('total_amount', ZERO), ZERO)),
                    And(
                        Eval('type') == 'in',
                        Less(Eval('total_amount', ZERO), ZERO))),
            ('kind', '=', 'receivable'),
            ('kind', '=', 'payable')),
            ],

[2]

for ZERO = '0.0' or ZERO = Decimal('0.0')

  File 
"/home/aneolf/workspace/trytond_default/trytond/trytond/modules/account_payment_type/invoice.py",
 
line 22, in Invoice
    Greater(Eval('total_amount', ZERO), ZERO)),
  File "/home/aneolf/workspace/trytond_default/trytond/trytond/pyson.py", 
line 317, in __init__
    'statement must be an integer or a float'
AssertionError: statement must be an integer or a float


[3]

for ZERO = 0.0

Traceback (most recent call last):
  File 
"/home/aneolf/workspace/trytond_default/tryton/tryton/gui/window/form.py", 
line 370, in sig_new
    self.screen.new()
  File 
"/home/aneolf/workspace/trytond_default/tryton/tryton/gui/window/view_form/screen/screen.py",
 
line 517, in new
    record = group.new(default)
  File 
"/home/aneolf/workspace/trytond_default/tryton/tryton/gui/window/view_form/model/group.py",
 
line 317, in new
    record.default_get()
  File 
"/home/aneolf/workspace/trytond_default/tryton/tryton/gui/window/view_form/model/record.py",
 
line 369, in default_get
    self.set_default(vals)
  File 
"/home/aneolf/workspace/trytond_default/tryton/tryton/gui/window/view_form/model/record.py",
 
line 433, in set_default
    self.validate(softvalidation=True)
  File 
"/home/aneolf/workspace/trytond_default/tryton/tryton/gui/window/view_form/model/record.py",
 
line 396, in validate
    if not field.validate(self, softvalidation, pre_validate):
  File 
"/home/aneolf/workspace/trytond_default/tryton/tryton/gui/window/view_form/model/field.py",
 
line 86, in validate
    domain = simplify(self.validation_domains(record, pre_validate))
  File 
"/home/aneolf/workspace/trytond_default/tryton/tryton/gui/window/view_form/model/field.py",
 
line 440, in validation_domains
    screen_domain, attr_domain = self.domains_get(record, pre_validate)
  File 
"/home/aneolf/workspace/trytond_default/tryton/tryton/gui/window/view_form/model/field.py",
 
line 53, in domains_get
    attr_domain = record.expr_eval(self.attrs.get('domain', []))
  File 
"/home/aneolf/workspace/trytond_default/tryton/tryton/gui/window/view_form/model/record.py",
 
line 503, in expr_eval
    val = PYSONDecoder(ctx).decode(expr)
  File "/usr/lib/python2.7/dist-packages/simplejson/decoder.py", line 370, 
in decode
    obj, end = self.raw_decode(s)
  File "/usr/lib/python2.7/dist-packages/simplejson/decoder.py", line 400, 
in raw_decode
    return self.scan_once(s, idx=_w(s, idx).end())
  File "/home/aneolf/workspace/trytond_default/tryton/tryton/pyson.py", 
line 138, in _object_hook
    return klass.eval(dct, self.__context)
  File "/home/aneolf/workspace/trytond_default/tryton/tryton/pyson.py", 
line 354, in eval
    dct = Greater._convert(dct)
  File "/home/aneolf/workspace/trytond_default/tryton/tryton/pyson.py", 
line 349, in _convert
    dct[i] = float(dct[i])
TypeError: float() argument must be a string or a number

-- 
You received this message because you are subscribed to the Google Groups 
"tryton" group.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tryton/60768f2c-1d1f-4039-88ff-d6edc4dd0394%40googlegroups.com.

Reply via email to