Browse Source

Merge pull request #900 from ankitjavalkarwork/fix2302

[#2302] Fix Report Builder reports when fetching info from child tables
version-14
Nabin Hait 10 years ago
parent
commit
9cf7651b59
1 changed files with 6 additions and 5 deletions
  1. +6
    -5
      frappe/model/db_query.py

+ 6
- 5
frappe/model/db_query.py View File

@@ -72,7 +72,12 @@ class DatabaseQuery(object):
self.fields.append(t + ".name as '%s:name'" % t[4:-1]) self.fields.append(t + ".name as '%s:name'" % t[4:-1])


# query dict # query dict
args.tables = ', '.join(self.tables)
args.tables = self.tables[0]

# left join parent, child tables
for tname in self.tables[1:]:
args.tables += " left join " + tname + " on " + tname + '.parent = ' + self.tables[0] + '.name'

if self.or_conditions: if self.or_conditions:
self.conditions.append("({0})".format(" or ".join(self.or_conditions))) self.conditions.append("({0})".format(" or ".join(self.or_conditions)))
args.conditions = ' and '.join(self.conditions) args.conditions = ' and '.join(self.conditions)
@@ -165,10 +170,6 @@ class DatabaseQuery(object):
self.build_filter_conditions(self.filters, self.conditions) self.build_filter_conditions(self.filters, self.conditions)
self.build_filter_conditions(self.or_filters, self.or_conditions) self.build_filter_conditions(self.or_filters, self.or_conditions)


# join parent, child tables
for tname in self.tables[1:]:
self.conditions.append(tname + '.parent = ' + self.tables[0] + '.name')

# match conditions # match conditions
if not self.ignore_permissions: if not self.ignore_permissions:
match_conditions = self.build_match_conditions() match_conditions = self.build_match_conditions()


Loading…
Cancel
Save