[MERGE] forward port branch saas-15 up to c43de33643
This commit is contained in:
@@ -1527,7 +1527,7 @@ class MailThread(models.AbstractModel):
|
|||||||
# Very unusual situation, be we should be fault-tolerant here
|
# Very unusual situation, be we should be fault-tolerant here
|
||||||
message_id = "<%s@localhost>" % time.time()
|
message_id = "<%s@localhost>" % time.time()
|
||||||
_logger.debug('Parsing Message without message-id, generating a random one: %s', message_id)
|
_logger.debug('Parsing Message without message-id, generating a random one: %s', message_id)
|
||||||
msg_dict['message_id'] = message_id
|
msg_dict['message_id'] = message_id.strip()
|
||||||
|
|
||||||
if message.get('Subject'):
|
if message.get('Subject'):
|
||||||
msg_dict['subject'] = tools.decode_smtp_header(message.get('Subject'))
|
msg_dict['subject'] = tools.decode_smtp_header(message.get('Subject'))
|
||||||
|
|||||||
@@ -18,3 +18,4 @@ access_test_new_api_company,access_test_new_api_company,model_test_new_api_compa
|
|||||||
access_test_new_api_company_attr,access_test_new_api_company_attr,model_test_new_api_company_attr,,1,1,1,1
|
access_test_new_api_company_attr,access_test_new_api_company_attr,model_test_new_api_company_attr,,1,1,1,1
|
||||||
access_test_new_api_compute_inverse,access_test_new_api_compute_inverse,model_test_new_api_compute_inverse,,1,1,1,1
|
access_test_new_api_compute_inverse,access_test_new_api_compute_inverse,model_test_new_api_compute_inverse,,1,1,1,1
|
||||||
access_test_new_api_recursive,access_test_new_api_recursive,model_test_new_api_recursive,,1,1,1,1
|
access_test_new_api_recursive,access_test_new_api_recursive,model_test_new_api_recursive,,1,1,1,1
|
||||||
|
access_test_new_api_cascade,access_test_new_api_cascade,model_test_new_api_cascade,,1,1,1,1
|
||||||
|
|||||||
|
@@ -380,3 +380,21 @@ class ComputeRecursive(models.Model):
|
|||||||
rec.display_name = rec.parent.display_name + " / " + rec.name
|
rec.display_name = rec.parent.display_name + " / " + rec.name
|
||||||
else:
|
else:
|
||||||
rec.display_name = rec.name
|
rec.display_name = rec.name
|
||||||
|
|
||||||
|
|
||||||
|
class ComputeCascade(models.Model):
|
||||||
|
_name = 'test_new_api.cascade'
|
||||||
|
|
||||||
|
foo = fields.Char()
|
||||||
|
bar = fields.Char(compute='_compute_bar') # depends on foo
|
||||||
|
baz = fields.Char(compute='_compute_baz', store=True) # depends on bar
|
||||||
|
|
||||||
|
@api.depends('foo')
|
||||||
|
def _compute_bar(self):
|
||||||
|
for record in self:
|
||||||
|
record.bar = "[%s]" % (record.foo or "")
|
||||||
|
|
||||||
|
@api.depends('bar')
|
||||||
|
def _compute_baz(self):
|
||||||
|
for record in self:
|
||||||
|
record.baz = "<%s>" % (record.bar or "")
|
||||||
@@ -228,6 +228,11 @@ class TestFields(common.TransactionCase):
|
|||||||
double_size = message.double_size
|
double_size = message.double_size
|
||||||
self.assertEqual(double_size, message.size)
|
self.assertEqual(double_size, message.size)
|
||||||
|
|
||||||
|
record = self.env['test_new_api.cascade'].create({'foo': "Hi"})
|
||||||
|
self.assertEqual(record.baz, "<[Hi]>")
|
||||||
|
record.foo = "Ho"
|
||||||
|
self.assertEqual(record.baz, "<[Ho]>")
|
||||||
|
|
||||||
def test_13_inverse(self):
|
def test_13_inverse(self):
|
||||||
""" test inverse computation of fields """
|
""" test inverse computation of fields """
|
||||||
Category = self.env['test_new_api.category']
|
Category = self.env['test_new_api.category']
|
||||||
|
|||||||
+8
-4
@@ -661,7 +661,7 @@ class Field(MetaField('DummyField', (object,), {})):
|
|||||||
# on ``path``. See method ``modified`` below for details.
|
# on ``path``. See method ``modified`` below for details.
|
||||||
#
|
#
|
||||||
|
|
||||||
def resolve_deps(self, model):
|
def resolve_deps(self, model, path0=[], seen=frozenset()):
|
||||||
""" Return the dependencies of ``self`` as tuples ``(model, field, path)``,
|
""" Return the dependencies of ``self`` as tuples ``(model, field, path)``,
|
||||||
where ``path`` is an optional list of field names.
|
where ``path`` is an optional list of field names.
|
||||||
"""
|
"""
|
||||||
@@ -672,11 +672,12 @@ class Field(MetaField('DummyField', (object,), {})):
|
|||||||
for dotnames in self.depends:
|
for dotnames in self.depends:
|
||||||
if dotnames == self.name:
|
if dotnames == self.name:
|
||||||
_logger.warning("Field %s depends on itself; please fix its decorator @api.depends().", self)
|
_logger.warning("Field %s depends on itself; please fix its decorator @api.depends().", self)
|
||||||
model, path = model0, dotnames.split('.')
|
model, path = model0, path0
|
||||||
for i, fname in enumerate(path):
|
for fname in dotnames.split('.'):
|
||||||
field = model._fields[fname]
|
field = model._fields[fname]
|
||||||
result.append((model, field, path[:i]))
|
result.append((model, field, path))
|
||||||
model = model0.env.get(field.comodel_name)
|
model = model0.env.get(field.comodel_name)
|
||||||
|
path = None if path is None else path + [fname]
|
||||||
|
|
||||||
# add self's model dependencies
|
# add self's model dependencies
|
||||||
for mname, fnames in model0._depends.items():
|
for mname, fnames in model0._depends.items():
|
||||||
@@ -686,11 +687,14 @@ class Field(MetaField('DummyField', (object,), {})):
|
|||||||
result.append((model, field, None))
|
result.append((model, field, None))
|
||||||
|
|
||||||
# add indirect dependencies from the dependencies found above
|
# add indirect dependencies from the dependencies found above
|
||||||
|
seen = seen.union([self])
|
||||||
for model, field, path in list(result):
|
for model, field, path in list(result):
|
||||||
for inv_field in model._field_inverses[field]:
|
for inv_field in model._field_inverses[field]:
|
||||||
inv_model = model0.env[inv_field.model_name]
|
inv_model = model0.env[inv_field.model_name]
|
||||||
inv_path = None if path is None else path + [field.name]
|
inv_path = None if path is None else path + [field.name]
|
||||||
result.append((inv_model, inv_field, inv_path))
|
result.append((inv_model, inv_field, inv_path))
|
||||||
|
if not field.store and field not in seen:
|
||||||
|
result += field.resolve_deps(model, path, seen)
|
||||||
|
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user