136
135
raise osv.except_osv(_('Error'), _('Operation not implemented!'))
138
def _get_restricted_area(self, cr, uid, ids, field_name, args, context=None):
146
for account_id in ids:
147
res[account_id] = True
150
def _search_restricted_area(self, cr, uid, ids, name, args, context=None):
152
Search the right domain to apply to this account filter.
153
For this, it uses the "ACCOUNT_RESTRICTED_AREA" variable in which we list all well-known cases.
154
The key args is "restricted_area", the param is like "register_lines".
155
In ACCOUNT_RESTRICTED_AREA, we use the param as key. It so return the domain to apply.
156
If no domain, return an empty domain.
163
if x[0] == 'restricted_area' and x[2]:
164
if x[2] in ACCOUNT_RESTRICTED_AREA:
165
for subdomain in ACCOUNT_RESTRICTED_AREA[x[2]]:
166
arg.append(subdomain)
167
elif x[0] != 'restricted_area':
170
raise osv.except_osv(_('Error'), _('Operation not implemented!'))
173
def _get_fake_cash_domain(self, cr, uid, ids, field_name, arg, context=None):
175
Fake method for domain
184
def _search_cash_domain(self, cr, uid, ids, field_names, args, context=None):
186
Return a given domain (defined in ACCOUNT_RESTRICTED_AREA variable)
192
if x[0] and x[1] == '=' and x[2]:
193
if x[2] in ['cash', 'bank', 'cheque']:
194
arg.append(('restricted_area', '=', 'journals'))
196
raise osv.except_osv(_('Error'), _('Operation not implemented!'))
140
200
'name': fields.char('Name', size=128, required=True, select=True, translate=True),
141
201
'type_for_register': fields.selection([('none', 'None'), ('transfer', 'Internal Transfer'), ('transfer_same','Internal Transfer (same currency)'),
147
207
'shrink_entries_for_hq': fields.boolean("Shrink entries for HQ export", help="Check this attribute if you want to consolidate entries on this account before they are exported to the HQ system."),
148
208
'filter_active': fields.function(_get_active, fnct_search=_search_filter_active, type="boolean", method=True, store=False, string="Show only active accounts",),
149
209
'is_analytic_addicted': fields.function(_get_is_analytic_addicted, fnct_search=_search_is_analytic_addicted, method=True, type='boolean', string='Analytic-a-holic?', help="Is this account addicted on analytic distribution?", store=False, readonly=True),
210
'restricted_area': fields.function(_get_restricted_area, fnct_search=_search_restricted_area, type='boolean', method=True, string="Is this account allowed?"),
211
'cash_domain': fields.function(_get_fake_cash_domain, fnct_search=_search_cash_domain, method=True, type='boolean', string="Domain used to search account in journals", help="This is only to change domain in journal's creation."),