~taktik/openobject-addons/hui-extra-6.1

« back to all changes in this revision

Viewing changes to account_bank_statement_voucher/account_voucher.py

  • Committer: Luc De Meyer
  • Date: 2014-03-12 19:53:31 UTC
  • Revision ID: luc.demeyer@noviat.com-20140312195331-lxqjtcbxg9h5dd7e
update accounting modules

Show diffs side-by-side

added added

removed removed

Lines of Context:
2
2
##############################################################################
3
3
#
4
4
#    OpenERP, Open Source Management Solution
5
 
#    
6
 
#    Copyright (c) 2012 Noviat nv/sa (www.noviat.be). All rights reserved.
7
 
 
5
#
 
6
#    Copyright (c) 2013 Noviat nv/sa (www.noviat.com). All rights reserved.
 
7
#
8
8
#    This program is free software: you can redistribute it and/or modify
9
9
#    it under the terms of the GNU Affero General Public License as
10
10
#    published by the Free Software Foundation, either version 3 of the
20
20
#
21
21
##############################################################################
22
22
 
23
 
from osv import fields, osv
24
 
from tools.translate import _
 
23
from openerp.osv import orm,fields
 
24
from openerp.tools.translate import _
 
25
from openerp import netsvc
25
26
from operator import itemgetter
26
 
import netsvc
27
27
import logging
28
28
_logger = logging.getLogger(__name__)
29
29
 
30
 
class account_voucher(osv.osv):
 
30
class account_voucher(orm.Model):
31
31
    _inherit = 'account.voucher'
32
32
 
33
33
    def _check_paid(self, cr, uid, ids, name, args, context=None):
41
41
            res[voucher.id] = ok
42
42
        return res
43
43
 
44
 
    _columns = {
45
 
        'paid': fields.function(_check_paid, string='Paid', type='boolean', help="The Voucher has been totally paid."),
46
 
    }
47
 
 
48
44
    def _get_narration(self, cr, uid, context=None):
49
45
        if context is None: context = {}
50
46
        if context.get('act_window_from_bank_statement'):           
90
86
        return context.get('invoice_id', False)
91
87
 
92
88
    _columns = {
 
89
        'paid': fields.function(_check_paid, string='Paid', type='boolean', help="The Voucher has been totally paid."),
93
90
        'invoice_id':fields.many2one('account.invoice', 'Invoice', readonly=True, states={'draft':[('readonly',False)]},
94
91
            help="Contains link to invoice, e.g. when the voucher is created via the Invoice 'Payment' button."),
95
92
        'stline_info': fields.function(_get_stline_info, method=True, string='Associated Bank Transaction', type='char', size=256, readonly=True),
129
126
                st_line_obj.write(cr, uid, [st_line.id], {'move_ids': [(4, move.id)]})
130
127
                move_line_obj.write(cr, uid, [x.id for x in move.line_id], {'statement_id': st_line.statement_id.id}, context=context)
131
128
        return res
132
 
          
133
 
account_voucher()
134
129
 
135
 
class account_voucher_line(osv.osv):
 
130
class account_voucher_line(orm.Model):
136
131
    """ 
137
132
    Remove voucher lines when associated accounting move is deleted (e.g. via cancel invoice).
138
133
    """
140
135
    _columns = {    
141
136
        'move_line_id': fields.many2one('account.move.line', 'Journal Item', ondelete='cascade'),
142
137
    }
143
 
account_voucher_line()
 
138