예제 #1
0
파일: query.py 프로젝트: niulinlnc/cubicerp
 def _get_alias_mapping(self):
     from odoo.osv.expression import get_alias_from_query
     mapping = {}
     for table in self.tables:
         alias, statement = get_alias_from_query(table)
         mapping[statement] = table
     return mapping
예제 #2
0
파일: query.py 프로젝트: niulinlnc/cubicerp
    def get_sql(self):
        """ Returns (query_from, query_where, query_params). """
        from odoo.osv.expression import get_alias_from_query
        tables_to_process = list(self.tables)
        alias_mapping = self._get_alias_mapping()
        from_clause = []
        from_params = []

        def add_joins_for_table(lhs):
            for (rhs, lhs_col, rhs_col, join) in self.joins.get(lhs, []):
                tables_to_process.remove(alias_mapping[rhs])
                from_clause.append(' %s %s ON ("%s"."%s" = "%s"."%s"' % \
                    (join, alias_mapping[rhs], lhs, lhs_col, rhs, rhs_col))
                extra = self.extras.get((lhs, (rhs, lhs_col, rhs_col, join)))
                if extra:
                    if extra[0]:
                        from_clause.append(' AND ')
                        from_clause.append(extra[0])
                    if extra[1]:
                        from_params.extend(extra[1])
                from_clause.append(')')
                add_joins_for_table(rhs)

        for pos, table in enumerate(tables_to_process):
            if pos > 0:
                from_clause.append(',')
            from_clause.append(table)
            table_alias = get_alias_from_query(table)[1]
            if table_alias in self.joins:
                add_joins_for_table(table_alias)

        return "".join(from_clause), " AND ".join(
            self.where_clause), from_params + self.where_clause_params
예제 #3
0
파일: query.py 프로젝트: 10537/odoo
 def _get_alias_mapping(self):
     from odoo.osv.expression import get_alias_from_query
     mapping = {}
     for table in self.tables:
         alias, statement = get_alias_from_query(table)
         mapping[statement] = table
     return mapping
예제 #4
0
파일: query.py 프로젝트: 10537/odoo
    def get_sql(self):
        """ Returns (query_from, query_where, query_params). """
        from odoo.osv.expression import get_alias_from_query
        tables_to_process = list(self.tables)
        alias_mapping = self._get_alias_mapping()
        from_clause = []
        from_params = []

        def add_joins_for_table(lhs):
            for (rhs, lhs_col, rhs_col, join) in self.joins.get(lhs, []):
                tables_to_process.remove(alias_mapping[rhs])
                from_clause.append(' %s %s ON ("%s"."%s" = "%s"."%s"' % \
                    (join, alias_mapping[rhs], lhs, lhs_col, rhs, rhs_col))
                extra = self.extras.get((lhs, (rhs, lhs_col, rhs_col, join)))
                if extra:
                    if extra[0]:
                        from_clause.append(' AND ')
                        from_clause.append(extra[0])
                    if extra[1]:
                        from_params.extend(extra[1])
                from_clause.append(')')
                add_joins_for_table(rhs)

        for pos, table in enumerate(tables_to_process):
            if pos > 0:
                from_clause.append(',')
            from_clause.append(table)
            table_alias = get_alias_from_query(table)[1]
            if table_alias in self.joins:
                add_joins_for_table(table_alias)

        return "".join(from_clause), " AND ".join(self.where_clause), from_params + self.where_clause_params
예제 #5
0
파일: query.py 프로젝트: niulinlnc/cubicerp
 def _get_table_aliases(self):
     from odoo.osv.expression import get_alias_from_query
     return [
         get_alias_from_query(from_statement)[1]
         for from_statement in self.tables
     ]
예제 #6
0
파일: query.py 프로젝트: 10537/odoo
 def _get_table_aliases(self):
     from odoo.osv.expression import get_alias_from_query
     return [get_alias_from_query(from_statement)[1] for from_statement in self.tables]