Browse Source

Merge pull request #296 from acsone/8.0-mis_builder_non_stored-cpi

[8.0][mis_builder] backport of fixes for #178 #193 #194
pull/303/head
Stéphane Bidoul (ACSONE) 8 years ago
committed by GitHub
parent
commit
7303fd6281
  1. 2
      mis_builder/models/aep.py
  2. 14
      mis_builder/models/mis_builder.py
  3. 1
      mis_builder/static/src/js/mis_builder.js

2
mis_builder/models/aep.py

@ -107,7 +107,7 @@ class AccountingExpressionProcessor(object):
self._account_ids_by_code[code].add(account.id)
for like_code in like_codes:
for account in account_model.\
search([('code', 'like', like_code),
search([('code', '=like', like_code),
('parent_id', 'child_of', root_account.id)]):
if account.type in ('view', 'consolidation'):
self._account_ids_by_code[like_code].update(

14
mis_builder/models/mis_builder.py

@ -332,15 +332,23 @@ class MisReport(models.Model):
domain.extend([(query.date_field.name, '>=', datetime_from),
(query.date_field.name, '<', datetime_to)])
field_names = [f.name for f in query.field_ids]
all_stored = all([model._fields[f].store for f in field_names])
if not query.aggregate:
data = model.search_read(domain, field_names)
res[query.name] = [AutoStruct(**d) for d in data]
elif query.aggregate == 'sum':
elif query.aggregate == 'sum' and all_stored:
# use read_group to sum stored fields
data = model.read_group(
domain, field_names, [])
s = AutoStruct(count=data[0]['__count'])
for field_name in field_names:
v = data[0][field_name]
try:
v = data[0][field_name]
except KeyError:
_logger.error('field %s not found in read_group '
'for %s; not summable?',
field_name, model._name)
v = AccountingNone
setattr(s, field_name, v)
res[query.name] = s
else:
@ -352,6 +360,8 @@ class MisReport(models.Model):
agg = _max
elif query.aggregate == 'avg':
agg = _avg
elif query.aggregate == 'sum':
agg = _sum
for field_name in field_names:
setattr(s, field_name,
agg([d[field_name] for d in data]))

1
mis_builder/static/src/js/mis_builder.js

@ -26,7 +26,6 @@ openerp.mis_builder = function(instance) {
self.mis_report_instance_id = self.getParent().datarecord.id
if (self.mis_report_instance_id) {
self.getParent().dataset.context['no_destroy'] = true;
self.generate_content();
} else {
self.display_settings();
}

Loading…
Cancel
Save