Skip to content
Permalink
Browse files

[MERGE] forward port branch saas-14 up to fa26279

  • Loading branch information...
KangOl committed Aug 19, 2019
2 parents 6668f69 + fa26279 commit c43de33643ab8fd7a26b943a3325272fbcda19d2
@@ -1508,7 +1508,7 @@ def message_parse(self, message, save_original=False):
# Very unusual situation, be we should be fault-tolerant here
message_id = "<%s@localhost>" % time.time()
_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'):
msg_dict['subject'] = tools.decode_smtp_header(message.get('Subject'))
@@ -17,3 +17,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_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_cascade,access_test_new_api_cascade,model_test_new_api_cascade,,1,1,1,1
@@ -364,4 +364,22 @@ def _compute_display_name(self):
if rec.parent:
rec.display_name = rec.parent.display_name + " / " + rec.name
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 "")
@@ -223,6 +223,11 @@ def test_12_cascade(self):
double_size = message.double_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):
""" test inverse computation of fields """
Category = self.env['test_new_api.category']
@@ -686,7 +686,7 @@ def _search_company_dependent(self, records, operator, value):
# 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)``,
where ``path`` is an optional list of field names.
"""
@@ -697,11 +697,12 @@ def resolve_deps(self, model):
for dotnames in self.depends:
if dotnames == self.name:
_logger.warning("Field %s depends on itself; please fix its decorator @api.depends().", self)
model, path = model0, dotnames.split('.')
for i, fname in enumerate(path):
model, path = model0, path0
for fname in dotnames.split('.'):
field = model._fields[fname]
result.append((model, field, path[:i]))
result.append((model, field, path))
model = model0.env.get(field.comodel_name)
path = None if path is None else path + [fname]

# add self's model dependencies
for mname, fnames in model0._depends.iteritems():
@@ -711,11 +712,14 @@ def resolve_deps(self, model):
result.append((model, field, None))

# add indirect dependencies from the dependencies found above
seen = seen.union([self])
for model, field, path in list(result):
for inv_field in model._field_inverses[field]:
inv_model = model0.env[inv_field.model_name]
inv_path = None if path is None else path + [field.name]
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

0 comments on commit c43de33

Please sign in to comment.
You can’t perform that action at this time.