Skip to content

Commit

Permalink
Remove active functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
lasley committed May 3, 2017
1 parent fecfb59 commit faa4fc9
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 70 deletions.
4 changes: 1 addition & 3 deletions base_multi_company/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@
Multi Company Base
==================

This module provides base multi company logic and mixers. Currently:

* Deactivation by company and mixer
This module provides an abstract model to be inherited by models that need to implement multi-company functionality.

Installation
============
Expand Down
22 changes: 0 additions & 22 deletions base_multi_company/models/multi_company_abstract.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@ class MultiCompanyAbstract(models.AbstractModel):
_name = 'multi.company.abstract'
_description = 'Multi-Company Abstract'

active = fields.Boolean(
company_dependent=True,
)
company_id = fields.Many2one(
string='Company',
comodel_name='res.company',
Expand All @@ -38,22 +35,3 @@ def _default_company_ids(self):
def _compute_company_id(self):
for record in self:
record.company_id = record.company_ids[:1].id

@api.model_cr
def init(self):
res = super(MultiCompanyAbstract, self).init()
Properties = self.env['ir.property']
field = self.env['ir.model.fields'].search([
('model', '=', self._name),
('name', '=', 'active'),
])
property = Properties.search([
('fields_id', '=', field.id),
])
if not property:
Properties.create({
'fields_id': field.id,
'type': 'binary',
'value_binary': True,
})
return res
45 changes: 0 additions & 45 deletions base_multi_company/tests/test_multi_company_abstract.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,48 +91,3 @@ def test_compute_company_id(self):
self.record.company_id.id,
self.record.company_ids[0].id,
)

def test_active_by_company_regular_user(self):
""" It should respect company rights during deactivation (non-sudo).
"""
self.add_company(self.company_2)
other_user = self.env.ref('base.user_demo')
self.switch_user_company(other_user, self.company_2)
record = self.record.sudo(other_user)
self.assertTrue(record.active,
'Record should start as active')
record.active = False
self.assertFalse(record.active,
'Record should have been changed to active.')
self.assertTrue(record.sudo().active,
'Record was deactivated in other companies.')

def test_active_by_company_admin_user(self):
""" It should respect company rights during deactivation (non-sudo).
"""
self.add_company(self.company_2)
other_user = self.env.ref('base.user_demo')
self.switch_user_company(other_user, self.company_2)
self.assertTrue(self.record.sudo(other_user).active,
'Record should start as active')
self.record.active = False
self.assertFalse(self.record.active,
'Record should have been changed to active.')
self.assertTrue(self.record.sudo(other_user).active,
'Record was deactivated in other companies.')

def test_active_by_company_search_false(self):
""" It should allow for search of inactive records. """
self.record.active = False
self.assertFalse(self.record.active,
'Record should be inactive.')
matches = self.Model.search([('active', '=', False),])
self.assertEqual(len(matches), 1)

def test_active_by_company_search_true(self):
""" It should allow for search of active records. """
self.assertTrue(self.record.active,
'Record should be active.')
matches = self.Model.search([('active', '=', True),])
self.assertEqual(len(matches), 1)

0 comments on commit faa4fc9

Please sign in to comment.