|
@ -87,6 +87,11 @@ def _get_bal_vars_in_report(report): |
|
|
return res |
|
|
return res |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def _is_valid_python_var(name): |
|
|
|
|
|
return re.match("[_A-Za-z][_a-zA-Z0-9]*$", name) \ |
|
|
|
|
|
and not name.startswith('bal_') |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class mis_report_kpi(orm.Model): |
|
|
class mis_report_kpi(orm.Model): |
|
|
|
|
|
|
|
|
""" A KPI is an element of a MIS report. |
|
|
""" A KPI is an element of a MIS report. |
|
@ -144,10 +149,8 @@ class mis_report_kpi(orm.Model): |
|
|
_order = 'sequence' |
|
|
_order = 'sequence' |
|
|
|
|
|
|
|
|
def _check_name(self, cr, uid, ids, context=None): |
|
|
def _check_name(self, cr, uid, ids, context=None): |
|
|
# TODO: kpi name cannot start with bal |
|
|
|
|
|
# TODO: factor out the name check function (DRY) |
|
|
|
|
|
for record_name in self.read(cr, uid, ids, ['name']): |
|
|
for record_name in self.read(cr, uid, ids, ['name']): |
|
|
if not re.match("[_A-Za-z][_a-zA-Z0-9]*$", record_name['name']): |
|
|
|
|
|
|
|
|
if not _is_valid_python_var(record_name['name']): |
|
|
return False |
|
|
return False |
|
|
return True |
|
|
return True |
|
|
|
|
|
|
|
@ -156,10 +159,8 @@ class mis_report_kpi(orm.Model): |
|
|
] |
|
|
] |
|
|
|
|
|
|
|
|
def onchange_name(self, cr, uid, ids, name, context=None): |
|
|
def onchange_name(self, cr, uid, ids, name, context=None): |
|
|
# TODO: factor out the name check function (DRY) |
|
|
|
|
|
# check it is a valid python identifier |
|
|
|
|
|
res = {} |
|
|
res = {} |
|
|
if name and not re.match("[_A-Za-z][_a-zA-Z0-9]*$", name): |
|
|
|
|
|
|
|
|
if name and not _is_valid_python_var(name): |
|
|
res['warning'] = { |
|
|
res['warning'] = { |
|
|
'title': 'Invalid name', |
|
|
'title': 'Invalid name', |
|
|
'message': 'The name must be a valid python identifier'} |
|
|
'message': 'The name must be a valid python identifier'} |
|
@ -167,7 +168,7 @@ class mis_report_kpi(orm.Model): |
|
|
|
|
|
|
|
|
def onchange_description(self, cr, uid, ids, description, name, |
|
|
def onchange_description(self, cr, uid, ids, description, name, |
|
|
context=None): |
|
|
context=None): |
|
|
# construct name from description |
|
|
|
|
|
|
|
|
""" construct name from description """ |
|
|
res = {} |
|
|
res = {} |
|
|
if description and not name: |
|
|
if description and not name: |
|
|
res = {'value': {'name': _python_var(description)}} |
|
|
res = {'value': {'name': _python_var(description)}} |
|
@ -291,10 +292,8 @@ class mis_report_query(orm.Model): |
|
|
_order = 'name' |
|
|
_order = 'name' |
|
|
|
|
|
|
|
|
def _check_name(self, cr, uid, ids, context=None): |
|
|
def _check_name(self, cr, uid, ids, context=None): |
|
|
# TODO: factor out the name check function (DRY) |
|
|
|
|
|
# TODO: query name must start with bal |
|
|
|
|
|
for record_name in self.read(cr, uid, ids, ['name']): |
|
|
for record_name in self.read(cr, uid, ids, ['name']): |
|
|
if not re.match("[_A-Za-z][_a-zA-Z0-9]*$", record_name['name']): |
|
|
|
|
|
|
|
|
if not _is_valid_python_var(record_name['name']): |
|
|
return False |
|
|
return False |
|
|
return True |
|
|
return True |
|
|
|
|
|
|
|
@ -470,7 +469,9 @@ class mis_report_instance_period(orm.Model): |
|
|
'period_id', |
|
|
'period_id', |
|
|
'compare_period_id', |
|
|
'compare_period_id', |
|
|
string='Compare with'), |
|
|
string='Compare with'), |
|
|
'company_id': fields.many2one('res.company', 'Company', required=True), |
|
|
|
|
|
|
|
|
'company_id': fields.related('report_instance_id', 'company_id', |
|
|
|
|
|
type="many2one", relation="res.company", |
|
|
|
|
|
string="Company", readonly=True), |
|
|
'normalize_factor': fields.integer( |
|
|
'normalize_factor': fields.integer( |
|
|
string='Factor', |
|
|
string='Factor', |
|
|
help='Factor to use to normalize the period (used in comparison'), |
|
|
help='Factor to use to normalize the period (used in comparison'), |
|
@ -481,11 +482,6 @@ class mis_report_instance_period(orm.Model): |
|
|
'duration': 1, |
|
|
'duration': 1, |
|
|
'sequence': 100, |
|
|
'sequence': 100, |
|
|
'normalize_factor': 1, |
|
|
'normalize_factor': 1, |
|
|
'company_id': lambda s, cr, uid, c: |
|
|
|
|
|
s.pool.get('res.company')._company_default_get( |
|
|
|
|
|
cr, uid, |
|
|
|
|
|
'mis.report.instance.period', |
|
|
|
|
|
context=c) |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
_order = 'sequence' |
|
|
_order = 'sequence' |
|
@ -663,10 +659,16 @@ class mis_report_instance(orm.Model): |
|
|
'target_move': fields.selection([('posted', 'All Posted Entries'), |
|
|
'target_move': fields.selection([('posted', 'All Posted Entries'), |
|
|
('all', 'All Entries'), |
|
|
('all', 'All Entries'), |
|
|
], 'Target Moves', required=True), |
|
|
], 'Target Moves', required=True), |
|
|
|
|
|
'company_id': fields.many2one('res.company', 'Company', required=True), |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
_defaults = { |
|
|
_defaults = { |
|
|
'target_move': 'posted', |
|
|
'target_move': 'posted', |
|
|
|
|
|
'company_id': lambda s, cr, uid, c: |
|
|
|
|
|
s.pool.get('res.company')._company_default_get( |
|
|
|
|
|
cr, uid, |
|
|
|
|
|
'mis.report.instance', |
|
|
|
|
|
context=c) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
def create(self, cr, uid, vals, context=None): |
|
|
def create(self, cr, uid, vals, context=None): |
|
|