Module: Ooor::Report::ClassMethods

Defined in:
lib/ooor/report.rb

Instance Method Summary collapse

Instance Method Details

#get_report_data(report_name, ids, report_type = 'pdf', context = {}) ⇒ Object



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/ooor/report.rb', line 25

def get_report_data(report_name, ids, report_type='pdf', context={})
  report_id = report(report_name, ids, report_type, context)
  if report_id
    state = false
    attempt = 0
    while not state
      report = self.report_get(report_id)
      state = report["state"]
      attempt = 1
      if not state
        sleep(0.1)
        attempt += 1
      else
        return [report["result"],report["format"]]
      end
      if attempt > 100
        logger.debug "OOOR RPC: 'Printing Aborted!'"
        break
      end
    end
  else
    logger.debug "OOOR RPC: 'report not found'"
  end
  return nil
end

#report(report_name, ids, report_type = 'pdf', context = {}) ⇒ Object

Added methods to obtain report data for a model



9
10
11
12
13
14
15
16
# File 'lib/ooor/report.rb', line 9

def report(report_name, ids, report_type='pdf', context={}) #TODO move to ReportService
  context = session.object.inject_session_context(:report, false, context)[0]
  uid = @session.config[:user_id]
  pass = @session.config[:password]
  db = @session.config[:database]
  params = {model: openerp_model, id: ids[0], report_type: report_type}
  session.report.report(db, uid, pass, report_name, ids, params, context)
end

#report_get(report_id) ⇒ Object



18
19
20
21
22
23
# File 'lib/ooor/report.rb', line 18

def report_get(report_id)
  uid = @session.config[:user_id]
  pass = @session.config[:password]
  db = @session.config[:database]
  session.report.report_get(db, uid, pass, report_id)
end