Browse Source

Remove reference to the model_name on rules

Because the model has been removed earlier (dead code)
pull/208/head
Guewen Baconnier 9 years ago
parent
commit
8ff2ee2418
  1. 12
      partner_changeset/models/changeset_field_rule.py
  2. 1
      partner_changeset/models/res_partner_changeset.py
  3. 18
      partner_changeset/tests/test_changeset_field_rule.py

12
partner_changeset/models/changeset_field_rule.py

@ -82,10 +82,6 @@ class ChangesetFieldRule(models.Model):
"""
return self.env.ref('base.model_res_users')
@api.model
def _default_model_id(self):
return self.env.ref('base.model_res_partner').id
@api.model
def _selection_action(self):
return [('auto', 'Auto'),
@ -93,9 +89,9 @@ class ChangesetFieldRule(models.Model):
('never', 'Never'),
]
@ormcache()
@ormcache(skiparg=1)
@api.model
def _get_rules(self, model_name, source_model_name):
def _get_rules(self, source_model_name):
""" Cache rules
Keep only the id of the rules, because if we keep the recordsets
@ -124,7 +120,7 @@ class ChangesetFieldRule(models.Model):
return result
@api.model
def get_rules(self, model_name, source_model_name):
def get_rules(self, source_model_name):
""" Return the rules for a model
When a model is specified, it will return the rules for this
@ -141,7 +137,7 @@ class ChangesetFieldRule(models.Model):
they want only global rules.
"""
rules = {}
cached_rules = self._get_rules(model_name, source_model_name)
cached_rules = self._get_rules(source_model_name)
for field, rule_id in cached_rules.iteritems():
rules[field] = self.browse(rule_id)
return rules

1
partner_changeset/models/res_partner_changeset.py

@ -134,7 +134,6 @@ class ResPartnerChangeset(models.Model):
write_values = values.copy()
changes = []
rules = self.env['changeset.field.rule'].get_rules(
record._model._name,
source_model_name=source_model,
)
for field in values:

18
partner_changeset/tests/test_changeset_field_rule.py

@ -41,7 +41,7 @@ class TestChangesetFieldRule(common.TransactionCase):
'field_id': self.field_street.id,
'action': 'never',
})
get_rules = ChangesetFieldRule.get_rules('res.partner', None)
get_rules = ChangesetFieldRule.get_rules(None)
self.assertEqual(get_rules, {'name': rule1, 'street': rule2})
def test_get_rules_source(self):
@ -61,10 +61,10 @@ class TestChangesetFieldRule(common.TransactionCase):
'action': 'never',
})
model = ChangesetFieldRule
rules = model.get_rules('res.partner', None)
self.assertEqual(rules, {'name': rule1, 'street': rule2})
rules = model.get_rules('res.partner', 'res.company')
self.assertEqual(rules, {'name': rule1, 'street': rule3})
rules = model.get_rules(None)
self.assertEqual(rules, {u'name': rule1, u'street': rule2})
rules = model.get_rules('res.company')
self.assertEqual(rules, {u'name': rule1, u'street': rule3})
def test_get_rules_cache(self):
ChangesetFieldRule = self.env['changeset.field.rule']
@ -74,7 +74,7 @@ class TestChangesetFieldRule(common.TransactionCase):
'action': 'validate',
})
self.assertEqual(
ChangesetFieldRule.get_rules('res.partner', None)['name'].action,
ChangesetFieldRule.get_rules(None)['name'].action,
'validate',
)
# Write on cursor to bypass the cache invalidation for the
@ -83,13 +83,13 @@ class TestChangesetFieldRule(common.TransactionCase):
"SET action = 'never' "
"WHERE id = %s", (rule.id,))
self.assertEqual(
ChangesetFieldRule.get_rules('res.partner', None)['name'].action,
ChangesetFieldRule.get_rules(None)['name'].action,
'validate',
)
rule.action = 'auto'
self.assertEqual(
ChangesetFieldRule.get_rules('res.partner', None)['name'].action,
ChangesetFieldRule.get_rules(None)['name'].action,
'auto',
)
rule.unlink()
self.assertFalse(ChangesetFieldRule.get_rules('res.partner', None))
self.assertFalse(ChangesetFieldRule.get_rules(None))
Loading…
Cancel
Save