Skip to content
Snippets Groups Projects
Commit f86e2a9f1516 authored by Houzefa Abbasbhay's avatar Houzefa Abbasbhay :slight_smile:
Browse files

usable_per_company -> disabled_per_company

parent 6ba4bbed54f8
No related branches found
No related tags found
No related merge requests found
...@@ -103,7 +103,7 @@ ...@@ -103,7 +103,7 @@
domain=[ domain=[
(domain_field, '=', model_name), (domain_field, '=', model_name),
('view_type', '=', False), ('view_type', '=', False),
('usable_per_company', '=', True), ('disabled_per_company', '=', False),
], ],
track_visibility='onchange', track_visibility='onchange',
) )
......
...@@ -31,6 +31,6 @@ ...@@ -31,6 +31,6 @@
_parent_order = 'name' _parent_order = 'name'
_order = 'parent_left' _order = 'parent_left'
def _read_usable_per_company( def _read_disabled_per_company(
self, cr, uid, ids, field_name, arg, context self, cr, uid, ids, field_name, arg, context
): ):
...@@ -35,7 +35,7 @@ ...@@ -35,7 +35,7 @@
self, cr, uid, ids, field_name, arg, context self, cr, uid, ids, field_name, arg, context
): ):
"""Mark the code as usable when it is not in the blacklist (depending """Mark the code as disabled when it is in the blacklist (depending on
on the current user's company). the current user's company).
""" """
anc_obj = self.pool['analytic.code'] anc_obj = self.pool['analytic.code']
...@@ -49,7 +49,7 @@ ...@@ -49,7 +49,7 @@
for anc in anc_obj.browse(cr, uid, ids, context=context): for anc in anc_obj.browse(cr, uid, ids, context=context):
blacklist = (company.id for company in anc.blacklist_ids) blacklist = (company.id for company in anc.blacklist_ids)
ret[anc.id] = company_id not in blacklist ret[anc.id] = company_id in blacklist
return ret return ret
...@@ -53,7 +53,7 @@ ...@@ -53,7 +53,7 @@
return ret return ret
def _write_usable_per_company( def _write_disabled_per_company(
self, cr, uid, anc_id, field_name, field_value, arg, context self, cr, uid, anc_id, field_name, field_value, arg, context
): ):
"""Update the blacklist depending on the current user's company. """Update the blacklist depending on the current user's company.
...@@ -70,5 +70,7 @@ ...@@ -70,5 +70,7 @@
blacklist = (company.id for company in anc.blacklist_ids) blacklist = (company.id for company in anc.blacklist_ids)
to_write = None to_write = None
if field_value and company_id in blacklist: if field_value and company_id not in blacklist:
to_write = [(4, company_id)] # Link.
elif not field_value and company_id in blacklist:
to_write = [(3, company_id)] # Unlink. to_write = [(3, company_id)] # Unlink.
...@@ -74,6 +76,4 @@ ...@@ -74,6 +76,4 @@
to_write = [(3, company_id)] # Unlink. to_write = [(3, company_id)] # Unlink.
elif not field_value and company_id not in blacklist:
to_write = [(4, company_id)] # Link.
if to_write: if to_write:
anc_obj.write( anc_obj.write(
...@@ -82,7 +82,7 @@ ...@@ -82,7 +82,7 @@
return True return True
def _search_usable_per_company( def _search_disabled_per_company(
self, cr, uid, model_again, field_name, criterion, context self, cr, uid, model_again, field_name, criterion, context
): ):
"""Update the domain to take the blacklist into account (depending on """Update the domain to take the blacklist into account (depending on
...@@ -95,7 +95,7 @@ ...@@ -95,7 +95,7 @@
cr, uid, [uid], ['company_id'], context=context cr, uid, [uid], ['company_id'], context=context
)[0]['company_id'][0] )[0]['company_id'][0]
# We assume the criterion was "usable_per_company = True". # We assume the criterion was "disabled_per_company = False".
return [ return [
'|', '|',
('blacklist_ids', '=', False), ('blacklist_ids', '=', False),
...@@ -137,9 +137,9 @@ ...@@ -137,9 +137,9 @@
u"Blacklist", u"Blacklist",
help=u"Companies the code is hidden in.", help=u"Companies the code is hidden in.",
), ),
'usable_per_company': fields.function( 'disabled_per_company': fields.function(
_read_usable_per_company, _read_disabled_per_company,
fnct_inv=_write_usable_per_company, fnct_inv=_write_disabled_per_company,
fnct_search=_search_usable_per_company, fnct_search=_search_disabled_per_company,
method=True, method=True,
type='boolean', type='boolean',
...@@ -144,7 +144,11 @@ ...@@ -144,7 +144,11 @@
method=True, method=True,
type='boolean', type='boolean',
store=False, # Not persistent as it dpeends on the company. store=False, # Not persistent as it depends on the company.
string=u"Usable in my company", string=u"Disabled in my company",
help=(
u"Determines whether an analytic code is disabled for the "
u"current company."
),
), ),
'nd_name': fields.related( 'nd_name': fields.related(
...@@ -177,7 +181,7 @@ ...@@ -177,7 +181,7 @@
_defaults = { _defaults = {
'active': lambda *a: True, 'active': lambda *a: True,
'view_type': lambda *a: False, 'view_type': lambda *a: False,
'usable_per_company': lambda *a: True, 'disabled_per_company': lambda *a: False,
} }
_constraints = [ _constraints = [
......
...@@ -33,7 +33,7 @@ ...@@ -33,7 +33,7 @@
<field name="id" invisible="1" /> <field name="id" invisible="1" />
<field name="active" /> <field name="active" />
<field name="view_type" invisible="1" /> <field name="view_type" invisible="1" />
<field name="usable_per_company" /> <field name="disabled_per_company" />
<field name="name" /> <field name="name" />
<field name="description" /> <field name="description" />
<field name="nd_id" <field name="nd_id"
...@@ -70,7 +70,7 @@ ...@@ -70,7 +70,7 @@
<group> <group>
<field name="active" /> <field name="active" />
<field name="view_type" invisible="1" /> <field name="view_type" invisible="1" />
<field name="usable_per_company" /> <field name="disabled_per_company" />
</group> </group>
<group colspan="2"> <group colspan="2">
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment