def get_rows(self, request, model=None, parent_id=None, fields=None, child_field=None, domain=None, dynatrees=None): obj = request.session.model(model) for k, v in dynatrees.items(): # k is str or ID is numeric del dynatrees[k] dynatrees[int(k)] = v context = self.get_context(request, obj, dynatrees, request.context) registry = RegistryManager.get(request.session._db) if hasattr(registry.get(model), 'tree_dynatree_get_rows'): return obj.tree_dynatree_get_rows( parent_id=parent_id, fields=fields, child_field=child_field, domain=domain, dynatrees=dynatrees, context=context) if parent_id: child_ids = obj.read( parent_id, [child_field], context=context)[child_field] else: domain = self.get_domain( request, obj, domain, dynatrees, context=context) child_ids = obj.search(domain, context=context) return obj.read(child_ids, fields + [child_field], context=context)
def autocomplete_data(self, request, model=None, searchText=None): obj = request.session.model(model) context = request.context registry = RegistryManager.get(request.session._db) if hasattr(registry.get(model), 'autocomplete_data'): return obj.autocomplete_data( model, searchText, context=context) view = request.session.model('ir.ui.view.chart.d3') return view.autocomplete_data( model, searchText, context=context)
def get_domain(self, request, obj, domain, dynatrees, context=None): if domain is None: domain = [] registry = RegistryManager.get(request.session._db) if hasattr(registry.get(obj.model), 'tree_dynatree_get_domain'): return obj.tree_dynatree_get_domain( domain, dynatrees, context=context) dynatree = request.session.model('ir.actions.act_window.dynatree') for d in dynatree.read(dynatrees.keys(), ['type', 'search_field', 'search_operator'], context=context): if d['type'] == 'domain': domain.append((d['search_field'], d['search_operator'], dynatrees[d['id']])) return domain
def get_context(self, request, obj, dynatrees, context=None): registry = RegistryManager.get(request.session._db) if hasattr(registry.get(obj.model), 'tree_dynatree_get_context'): return obj.tree_dynatree_get_context(dynatrees, context=context) if context is None: context = {} ctx = context.copy() dynatree = request.session.model('ir.actions.act_window.dynatree') for d in dynatree.read(dynatrees.keys(), ['type', 'search_field'], context=context): if d['type'] == 'context': ctx.update({d['search_field']: dynatrees[d['id']]}) return ctx
def export(self, request, data, token): kwargs = simplejson.loads(data) start_date = kwargs.get('start_date') end_date = kwargs.get('end_date') model = kwargs.get('model') obj = request.session.model(model) registry = RegistryManager.get(request.session._db) if hasattr(registry.get(model), 'export_data'): data = obj.export_data( start_date,end_date) header = obj.export_header( start_date,end_date) return request.make_response(self.from_data(header, data), headers=[('Content-Disposition', self.content_disposition(request,"ChartData.csv")), ('Content-Type', 'text/csv;charset=utf8')], cookies={'fileToken': token}) raise osv.except_osv(('Error'), ('Functionality not enabled'))
def get_data(self, request, model=None, xaxis=None, yaxis=None, domain=None, group_by=None, options=None): if domain is None: domain = [] if group_by is None: group_by = [] if options is None: options = {} obj = request.session.model(model) context = request.context registry = RegistryManager.get(request.session._db) if hasattr(registry.get(model), "chart_d3_get_data"): return obj.chart_d3_get_data(xaxis, yaxis, domain, group_by, options, context=context) view = request.session.model("ir.ui.view.chart.d3") return view.get_data(model, xaxis, yaxis, domain, group_by, options, context=context)
def get_children(self, request, model=None, oerp_id=None, first_node_domain=[], domain=[], child_field='child_ids', checkbox_field=None, use_checkbox=False, selected_oerp_ids=None): context = request.context obj = request.session.model(model) registry = RegistryManager.get(request.session._db) if hasattr(registry.get(model), 'dynatree_get_node'): return obj.dynatree_get_node( model=model, oerp_id=oerp_id, first_node_domain=first_node_domain, domain=domain, child_field=child_field, checkbox_field=checkbox_field, use_checkbox=use_checkbox, selected_oerp_ids=selected_oerp_ids, context=context) oerp_ids = self._get_oerp_ids( obj, oerp_id, first_node_domain, domain, child_field, context) return self._get_children_node( obj, model, oerp_ids, domain, child_field, checkbox_field, use_checkbox, selected_oerp_ids, context)