~unifield-team/unifield-wm/us-826

« back to all changes in this revision

Viewing changes to financing_contract/report/financing_contract.py

  • Committer: Matthieu Dietrich
  • Date: 2012-07-10 14:12:40 UTC
  • mfrom: (913 unifield-wm)
  • mto: This revision was merged to the branch mainline in revision 935.
  • Revision ID: mdietrich@chloups211-20120710141240-celi3o016fqz7mj1
UF-881: [MERGE] merged with trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
29
29
        super(contract, self).__init__(cr, uid, name, context=context)
30
30
        self.localcontext.update({
31
31
            'locale': locale,
 
32
            'process': self.process,
 
33
            'get_totals': self.get_totals,
32
34
        })
33
35
        return
34
36
        
 
37
 
 
38
    def get_totals(self, reporting_lines):
 
39
        result = [0, 0]
 
40
        # Parse each budget line
 
41
        
 
42
        for line in reporting_lines:
 
43
            if line.line_type != 'view':
 
44
                result[0] += line.allocated_budget
 
45
                result[1] += line.project_budget
 
46
        return result
 
47
    
 
48
    def process(self, reporting_lines):
 
49
        register_states = dict(self.pool.get('financing.contract.format.line')._columns['line_type'].selection)
 
50
        result = []
 
51
        # Parse each contract line
 
52
        for line in reporting_lines:
 
53
            account_list = ''
 
54
            for account in line.account_ids:
 
55
                account_list += str(account.code)
 
56
                account_list += ', '
 
57
            if len(account_list) > 2:
 
58
                account_list = account_list[:-2]
 
59
            values = {'code': line.code,
 
60
                      'name': line.name,
 
61
                      'allocated_budget': line.allocated_budget,
 
62
                      'project_budget': line.project_budget,
 
63
                      'line_type': register_states[line.line_type],
 
64
                      'account_list': account_list}
 
65
            result.append(values)
 
66
        return result
35
67
        
36
68
 
37
69
report_sxw.report_sxw('report.financing.contract', 'financing.contract.contract', 'addons/financing_contract/report/financing_contract.rml', parser=contract)