~koi-accounting-modules-maintainer/koi-accounting-modules/7.0-fixed-asset

« back to all changes in this revision

Viewing changes to koi_account_query/report/query_bank_in_out.py

  • Committer: Andhitia Rama
  • Date: 2014-07-07 08:21:41 UTC
  • Revision ID: andhitia.r@gmail.com-20140707082141-wfxrup4e7n5vxpai
Revisi :

1. Penambahan modul koi_account_aeroo_report
2. Penyesuaian bank in/out terhadap aeroo report

Show diffs side-by-side

added added

removed removed

Lines of Context:
29
29
    _name = 'account.query_bank_in_out'
30
30
    _description = 'Query Bank In/Out'
31
31
    _auto = False
 
32
    _order = 'date,id'
32
33
    _columns = {
33
34
                'name' : fields.char(string='Description', size=64),
34
35
                'move_id' : fields.many2one(string='# Move', obj='account.move'),
38
39
                'journal_id' : fields.many2one(string='Journal', obj='account.journal'),
39
40
                'partner_id' : fields.many2one(string='Partner', obj='res.partner'),
40
41
                'period_id' : fields.many2one(string='Period', obj='account.period'),
41
 
                'debit' : fields.float(string='Out'),
42
 
                'credit' : fields.float(string='In'),
 
42
                'debit' : fields.float(string='In'),
 
43
                'credit' : fields.float(string='Out'),
 
44
                'currency_id' : fields.many2one(string='Secondary Currency', obj='res.currency'),
 
45
                'debit_amount_currency' : fields.float(string='In'),
 
46
                'credit_amount_currency' : fields.float(string='Out'),
43
47
                'state' : fields.selection(string='State', selection=[('draft','Unposted'),('posted','Posted')]),
44
48
                            
45
49
 
61
65
                                B.period_id AS period_id,
62
66
                                A.debit AS debit,
63
67
                                A.credit AS credit,
64
 
                                B.state AS state
65
 
                        FROM account_move_line AS A
66
 
                        JOIN account_move AS B ON A.move_id = B.id
67
 
                        JOIN account_journal C ON B.journal_id = C.id
68
 
                        JOIN account_account D ON A.account_id = D.id
69
 
                        WHERE   (C.type = 'bank') AND
70
 
                                (D.type = 'other' OR D.type = 'receivable' or D.type = 'payable')
 
68
                                B.state AS state,
 
69
                                A.currency_id AS currency_id,
 
70
                                CASE
 
71
                                    WHEN A.amount_currency > 0 THEN A.amount_currency
 
72
                                    ELSE 0
 
73
                                END AS debit_amount_currency,
 
74
                                CASE
 
75
                                    WHEN A.amount_currency < 0 THEN ABS(A.amount_currency)
 
76
                                    ELSE 0
 
77
                                END AS credit_amount_currency
 
78
                        FROM    account_move_line AS A
 
79
                        JOIN    account_move AS B ON A.move_id = B.id
 
80
                        JOIN    account_journal C ON B.journal_id = C.id
 
81
                        JOIN    account_account D ON A.account_id = D.id
 
82
                        JOIN    (
 
83
                                SELECT  res_id,
 
84
                                        module,
 
85
                                        model,
 
86
                                        name
 
87
                                FROM    ir_model_data
 
88
                                WHERE   module = 'l10n_id_account_type' AND
 
89
                                        model = 'account.account.type' AND
 
90
                                        name = 'accountType_bank'
 
91
                                ) AS E ON D.user_type = E.res_id
 
92
                        WHERE   (C.type = 'bank')
 
93
                        ORDER BY    A.date,
 
94
                                                A.id
71
95
                    )
72
96
                    """
73
97
        
74
98
        
75
99
        cr.execute(strSQL)
76
100
 
77
 
    def fields_view_get(self, cr, uid, view_id=None, view_type='form', context=None, toolbar=False, submenu=False):
78
 
        obj_user = self.pool.get('res.users')
79
 
        obj_journal = self.pool.get('account.journal')
80
 
        obj_year = self.pool.get('account.fiscalyear')
81
 
 
82
 
        user = obj_user.browse(cr, uid, [uid])[0]
83
 
 
84
 
        res = super(query_bank_in_out, self).fields_view_get(cr, uid, view_id, view_type, context, toolbar, submenu)
85
 
 
86
 
        if view_type == 'search':
87
 
            doc = etree.XML(res['arch'])
88
 
 
89
 
            for node in doc.xpath("//group[@name='group_1']"):
90
 
                criteria = [('type','=','bank'),('company_id','=',user.company_id.id)]
91
 
                journal_ids = obj_journal.search(cr, uid, criteria)
92
 
 
93
 
                if journal_ids:
94
 
                    for journal in obj_journal.browse(cr, uid, journal_ids):
95
 
                        etree.SubElement(node, 'filter', string=journal.name, domain="[('journal_id','=',%s)]" % (journal.id))
96
 
 
97
 
 
98
 
            for node in doc.xpath("//group[@name='group_2']"):
99
 
                year_ids = obj_year.find(cr, uid)
100
 
                if year_ids:
101
 
                    fiscalyear = obj_year.browse(cr, uid, [year_ids])[0]
102
 
                    
103
 
                    if fiscalyear.period_ids:
104
 
                        for period in fiscalyear.period_ids:
105
 
                            etree.SubElement(node, 'filter', string=period.name, domain="[('period_id','=',%s)]" % (period.id))
106
 
 
107
 
            res['arch'] = etree.tostring(doc)
108
 
 
109
 
        return res
 
101
 
110
102
 
111
103
 
112
104