Browse Source

excel export - use dp

pull/86/head
laetitia.gangloff@acsone.eu 10 years ago
committed by Stéphane Bidoul
parent
commit
1fc11891a0
  1. 5
      mis_builder/models/mis_builder.py
  2. 13
      mis_builder/report/mis_builder_xls.py

5
mis_builder/models/mis_builder.py

@ -113,7 +113,7 @@ class mis_report_kpi(orm.Model):
'divider': '1', 'divider': '1',
'dp': 0, 'dp': 0,
'compare_method': 'pct', 'compare_method': 'pct',
'sequence': 1,
'sequence': 10,
} }
_order = 'sequence' _order = 'sequence'
@ -385,7 +385,7 @@ class mis_report_instance_period(orm.Model):
_defaults = { _defaults = {
'offset': -1, 'offset': -1,
'duration': 1, 'duration': 1,
'sequence': 1,
'sequence': 10,
'normalize_factor': 1, 'normalize_factor': 1,
'company_id': lambda s, cr, uid, c: s.pool.get('res.company')._company_default_get(cr, uid, 'company_id': lambda s, cr, uid, c: s.pool.get('res.company')._company_default_get(cr, uid,
'mis.report.instance.period', 'mis.report.instance.period',
@ -500,6 +500,7 @@ class mis_report_instance_period(orm.Model):
'val_c': kpi_val_comment, 'val_c': kpi_val_comment,
'style': kpi_style, 'style': kpi_style,
'suffix': kpi.suffix, 'suffix': kpi.suffix,
'dp': kpi.dp,
} }
return res return res

13
mis_builder/report/mis_builder_xls.py

@ -27,8 +27,6 @@ from openerp.addons.report_xls.report_xls import report_xls
import logging import logging
_logger = logging.getLogger(__name__) _logger = logging.getLogger(__name__)
_ir_translation_name = 'mis.report.instance.xls'
class mis_builder_xls_parser(report_sxw.rml_parse): class mis_builder_xls_parser(report_sxw.rml_parse):
@ -50,7 +48,6 @@ class mis_builder_xls(report_xls):
self.rh_cell_style_date = xlwt.easyxf(rh_cell_format, num_format_str=report_xls.date_format) self.rh_cell_style_date = xlwt.easyxf(rh_cell_format, num_format_str=report_xls.date_format)
# lines # lines
self.mis_rh_cell_style = xlwt.easyxf(_xs['borders_all'] + _xs['bold'] + _xs['fill']) self.mis_rh_cell_style = xlwt.easyxf(_xs['borders_all'] + _xs['bold'] + _xs['fill'])
self.mis_cell_style = xlwt.easyxf(_xs['borders_all'] + _xs['right'], num_format_str=report_xls.decimal_format)
def generate_xls_report(self, _p, _xs, data, objects, wb): def generate_xls_report(self, _p, _xs, data, objects, wb):
@ -91,6 +88,7 @@ class mis_builder_xls(report_xls):
c_specs = map(lambda x: self.render(x, col_specs_template, 'header_date'), header_name_list) c_specs = map(lambda x: self.render(x, col_specs_template, 'header_date'), header_name_list)
row_data = self.xls_row_template(c_specs, [x[0] for x in c_specs]) row_data = self.xls_row_template(c_specs, [x[0] for x in c_specs])
row_pos = self.xls_write_row(ws, row_pos, row_data, row_style=self.rh_cell_style_date) row_pos = self.xls_write_row(ws, row_pos, row_data, row_style=self.rh_cell_style_date)
ws.set_horz_split_pos(row_pos) ws.set_horz_split_pos(row_pos)
ws.set_vert_split_pos(1) ws.set_vert_split_pos(1)
@ -100,9 +98,14 @@ class mis_builder_xls(report_xls):
ws.write(row_pos, col, line['kpi_name'], self.mis_rh_cell_style) ws.write(row_pos, col, line['kpi_name'], self.mis_rh_cell_style)
for value in line['cols']: for value in line['cols']:
col += 1 col += 1
kpi_cell_style = self.mis_cell_style
num_format_str = '#'
if value.get('dp'):
num_format_str += '.'
for x in range(int(value['dp'])):
num_format_str = num_format_str + '#'
if value.get('suffix'): if value.get('suffix'):
kpi_cell_style = xlwt.easyxf(_xs['borders_all'] + _xs['right'], num_format_str='#,##0.00" %s"' % value['suffix'])
num_format_str = num_format_str + ' "%s"' % value['suffix']
kpi_cell_style = xlwt.easyxf(_xs['borders_all'] + _xs['right'], num_format_str=num_format_str)
if value.get('val'): if value.get('val'):
ws.write(row_pos, col, value['val'], kpi_cell_style) ws.write(row_pos, col, value['val'], kpi_cell_style)
else: else:

Loading…
Cancel
Save