[MERGE] Forward-port 7.0 up to 6acd5ef91c
This commit is contained in:
commit
9cdfb0696a
|
@ -418,7 +418,7 @@ class account_voucher(osv.osv):
|
||||||
'state': 'draft',
|
'state': 'draft',
|
||||||
'pay_now': 'pay_now',
|
'pay_now': 'pay_now',
|
||||||
'name': '',
|
'name': '',
|
||||||
'date': lambda *a: time.strftime('%Y-%m-%d'),
|
'date': fields.date.context_today,
|
||||||
'company_id': lambda self,cr,uid,c: self.pool.get('res.company')._company_default_get(cr, uid, 'account.voucher',context=c),
|
'company_id': lambda self,cr,uid,c: self.pool.get('res.company')._company_default_get(cr, uid, 'account.voucher',context=c),
|
||||||
'tax_id': _get_tax,
|
'tax_id': _get_tax,
|
||||||
'payment_option': 'without_writeoff',
|
'payment_option': 'without_writeoff',
|
||||||
|
|
|
@ -489,7 +489,7 @@ class ExtendedLeaf(object):
|
||||||
# i.e.: many2one: 'state_id': current field name
|
# i.e.: many2one: 'state_id': current field name
|
||||||
# --------------------------------------------------
|
# --------------------------------------------------
|
||||||
|
|
||||||
def __init__(self, leaf, model, join_context=None):
|
def __init__(self, leaf, model, join_context=None, internal=False):
|
||||||
""" Initialize the ExtendedLeaf
|
""" Initialize the ExtendedLeaf
|
||||||
|
|
||||||
:attr [string, tuple] leaf: operator or tuple-formatted domain
|
:attr [string, tuple] leaf: operator or tuple-formatted domain
|
||||||
|
@ -528,7 +528,7 @@ class ExtendedLeaf(object):
|
||||||
self._models.append(item[0])
|
self._models.append(item[0])
|
||||||
self._models.append(model)
|
self._models.append(model)
|
||||||
# check validity
|
# check validity
|
||||||
self.check_leaf()
|
self.check_leaf(internal)
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return '<osv.ExtendedLeaf: %s on %s (ctx: %s)>' % (str(self.leaf), self.model._table, ','.join(self._get_context_debug()))
|
return '<osv.ExtendedLeaf: %s on %s (ctx: %s)>' % (str(self.leaf), self.model._table, ','.join(self._get_context_debug()))
|
||||||
|
@ -574,7 +574,7 @@ class ExtendedLeaf(object):
|
||||||
# Leaf manipulation
|
# Leaf manipulation
|
||||||
# --------------------------------------------------
|
# --------------------------------------------------
|
||||||
|
|
||||||
def check_leaf(self):
|
def check_leaf(self, internal=False):
|
||||||
""" Leaf validity rules:
|
""" Leaf validity rules:
|
||||||
- a valid leaf is an operator or a leaf
|
- a valid leaf is an operator or a leaf
|
||||||
- a valid leaf has a field objects unless
|
- a valid leaf has a field objects unless
|
||||||
|
@ -583,7 +583,7 @@ class ExtendedLeaf(object):
|
||||||
- left is id, operator is 'child_of'
|
- left is id, operator is 'child_of'
|
||||||
- left is in MAGIC_COLUMNS
|
- left is in MAGIC_COLUMNS
|
||||||
"""
|
"""
|
||||||
if not is_operator(self.leaf) and not is_leaf(self.leaf, True):
|
if not is_operator(self.leaf) and not is_leaf(self.leaf, internal):
|
||||||
raise ValueError("Invalid leaf %s" % str(self.leaf))
|
raise ValueError("Invalid leaf %s" % str(self.leaf))
|
||||||
|
|
||||||
def is_operator(self):
|
def is_operator(self):
|
||||||
|
@ -602,14 +602,14 @@ class ExtendedLeaf(object):
|
||||||
self.leaf = normalize_leaf(self.leaf)
|
self.leaf = normalize_leaf(self.leaf)
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def create_substitution_leaf(leaf, new_elements, new_model=None):
|
def create_substitution_leaf(leaf, new_elements, new_model=None, internal=False):
|
||||||
""" From a leaf, create a new leaf (based on the new_elements tuple
|
""" From a leaf, create a new leaf (based on the new_elements tuple
|
||||||
and new_model), that will have the same join context. Used to
|
and new_model), that will have the same join context. Used to
|
||||||
insert equivalent leafs in the processing stack. """
|
insert equivalent leafs in the processing stack. """
|
||||||
if new_model is None:
|
if new_model is None:
|
||||||
new_model = leaf.model
|
new_model = leaf.model
|
||||||
new_join_context = [tuple(context) for context in leaf.join_context]
|
new_join_context = [tuple(context) for context in leaf.join_context]
|
||||||
new_leaf = ExtendedLeaf(new_elements, new_model, join_context=new_join_context)
|
new_leaf = ExtendedLeaf(new_elements, new_model, join_context=new_join_context, internal=internal)
|
||||||
return new_leaf
|
return new_leaf
|
||||||
|
|
||||||
class expression(object):
|
class expression(object):
|
||||||
|
@ -1061,7 +1061,7 @@ class expression(object):
|
||||||
'model',
|
'model',
|
||||||
right,
|
right,
|
||||||
)
|
)
|
||||||
push(create_substitution_leaf(leaf, ('id', inselect_operator, (subselect, params)), working_model))
|
push(create_substitution_leaf(leaf, ('id', inselect_operator, (subselect, params)), working_model, internal=True))
|
||||||
|
|
||||||
else:
|
else:
|
||||||
push_result(leaf)
|
push_result(leaf)
|
||||||
|
|
Loading…
Reference in New Issue