parent
8cfdddc6ca
commit
65d81f861c
|
@ -211,6 +211,10 @@ Starting load wizard::
|
|||
|
||||
Check UL loading restrictions::
|
||||
|
||||
>>> bool(Unitload.find([('id', '=', ul.id), ('load_order', '=', None)]))
|
||||
True
|
||||
>>> bool(Unitload.find([('id', '=', ul.id), ('load_order', '!=', None)]))
|
||||
False
|
||||
>>> start_load.form.ul_code = ul.code
|
||||
>>> start_load.execute('load_')
|
||||
Traceback (most recent call last):
|
||||
|
@ -223,6 +227,14 @@ Check UL loading restrictions::
|
|||
>>> not Unitload.find([('id', '=', ul.id), ('available', '=', False)])
|
||||
True
|
||||
>>> start_load.execute('load_')
|
||||
>>> bool(Unitload.find([('id', '=', ul.id), ('available', '=', False)]))
|
||||
True
|
||||
>>> bool(Unitload.find([('id', '=', ul.id), ('load_order', '=', None)]))
|
||||
False
|
||||
>>> bool(Unitload.find([('id', '=', ul.id), ('load_order', '!=', None)]))
|
||||
True
|
||||
>>> bool(Unitload.find([('id', '=', ul.id), ('load_order', '=', order)]))
|
||||
True
|
||||
>>> start_load.form.loaded_uls
|
||||
1
|
||||
>>> order.reload()
|
||||
|
@ -236,6 +248,14 @@ Check UL loading restrictions::
|
|||
False
|
||||
>>> not Unitload.find([('id', '=', order.unit_loads[0].id), ('available', '=', True)])
|
||||
True
|
||||
>>> bool(Unitload.find([('id', '=', ul.id), ('load_order', '=', None)]))
|
||||
False
|
||||
>>> bool(Unitload.find([('id', '=', ul.id), ('load_order', '!=', None)]))
|
||||
True
|
||||
>>> bool(Unitload.find([('id', '=', ul.id), ('load_order', '=', order.id)]))
|
||||
True
|
||||
>>> bool(Unitload.find([('id', '=', ul.id), ('load_order', '=', order)]))
|
||||
True
|
||||
>>> start_load.form.ul_code = ul.code
|
||||
>>> start_load.execute('load_')
|
||||
Traceback (most recent call last):
|
||||
|
|
42
unit_load.py
42
unit_load.py
|
@ -72,23 +72,33 @@ class UnitLoad(metaclass=PoolMeta):
|
|||
|
||||
@classmethod
|
||||
def search_load_order(cls, name, clause):
|
||||
_field = 'load_line.%s' % clause[0].replace(name, 'order', 1)
|
||||
_field2 = 'load_lines.%s' % clause[0].replace(name, 'order', 1)
|
||||
if '.' not in clause[0] and clause[2] is not None:
|
||||
if clause[2] is None or isinstance(clause[2], (
|
||||
int, list, tuple, set, Model)):
|
||||
_field += '.id'
|
||||
_field2 += '.id'
|
||||
join_operator = 'OR'
|
||||
cond1, cond2 = [], []
|
||||
|
||||
def get_field(_field):
|
||||
return '%s.%s' % (
|
||||
_field,
|
||||
clause[0].replace(name, 'order', 1))
|
||||
|
||||
if '.' not in clause[0]:
|
||||
if clause[2] is None:
|
||||
if clause[1] == '=':
|
||||
join_operator = 'AND'
|
||||
cond1.append(('load_line', ) + tuple(clause[1:]))
|
||||
cond2.append(('load_lines', ) + tuple(clause[1:]))
|
||||
else:
|
||||
_field += '.rec_name'
|
||||
_field2 += '.rec_name'
|
||||
return ['OR',
|
||||
[
|
||||
(_field, ) + tuple(clause[1:]),
|
||||
], [
|
||||
('load_line', '=', None),
|
||||
(_field2, ) + tuple(clause[1:])
|
||||
]
|
||||
cond1.append((get_field('load_line'), ) + tuple(clause[1:]))
|
||||
cond2.extend([
|
||||
('load_lines', '!=', None),
|
||||
(get_field('load_lines'), ) + tuple(clause[1:])
|
||||
])
|
||||
else:
|
||||
cond1.append((get_field('load_line'), ) + tuple(clause[1:]))
|
||||
cond2.append((get_field('load_lines'), ) + tuple(clause[1:]))
|
||||
|
||||
return [join_operator,
|
||||
cond1,
|
||||
cond2
|
||||
]
|
||||
|
||||
@classmethod
|
||||
|
|
Loading…
Reference in New Issue