[IMP] Make account.voucher inactive by default, and only change its state when confirming the corresponding bank statement. Improved bank statement unlink method, also removing its corresponding vouchers.
bzr revid: vta@openerp.com-20121106153602-jmtaqkn55o5hxwyv
This commit is contained in:
parent
c4fe6c2f58
commit
01d33d5d06
|
@ -267,6 +267,7 @@ class account_voucher(osv.osv):
|
|||
_order = "date desc, id desc"
|
||||
# _rec_name = 'number'
|
||||
_columns = {
|
||||
'active':fields.boolean('Active', help="If the active field is set to False, it will allow you to hide the payment term without removing it."),
|
||||
'type':fields.selection([
|
||||
('sale','Sale'),
|
||||
('purchase','Purchase'),
|
||||
|
@ -328,6 +329,7 @@ class account_voucher(osv.osv):
|
|||
'is_multi_currency': fields.boolean('Multi Currency Voucher', help='Fields with internal purpose only that depicts if the voucher is a multi currency one or not'),
|
||||
}
|
||||
_defaults = {
|
||||
'active': lambda *a: False,
|
||||
'period_id': _get_period,
|
||||
'partner_id': _get_partner,
|
||||
'journal_id':_get_journal,
|
||||
|
@ -1504,6 +1506,15 @@ account_voucher_line()
|
|||
class account_bank_statement(osv.osv):
|
||||
_inherit = 'account.bank.statement'
|
||||
|
||||
def button_confirm_bank(self, cr, uid, ids, context=None):
|
||||
statementLine = self.pool.get('account.bank.statement.line')
|
||||
voucher = self.pool.get('account.voucher')
|
||||
for statement in self.browse(cr, uid, ids, context=context):
|
||||
for line in statement.line_ids:
|
||||
if line.voucher_id:
|
||||
voucher.write(cr, uid, line.voucher_id.id, {'active':True}, context=context)
|
||||
return super(account_bank_statement, self).button_confirm_bank(cr, uid, ids, context=context)
|
||||
|
||||
def button_cancel(self, cr, uid, ids, context=None):
|
||||
voucher_obj = self.pool.get('account.voucher')
|
||||
for st in self.browse(cr, uid, ids, context=context):
|
||||
|
@ -1534,6 +1545,13 @@ class account_bank_statement(osv.osv):
|
|||
return move_line_obj.write(cr, uid, [x.id for x in v.move_ids], {'statement_id': st_line.statement_id.id}, context=context)
|
||||
return super(account_bank_statement, self).create_move_from_st_line(cr, uid, st_line.id, company_currency_id, next_number, context=context)
|
||||
|
||||
def unlink(self, cr, uid, ids, context=None):
|
||||
statementLine = self.pool.get('account.bank.statement.line')
|
||||
for statement in self.read(cr, uid, ids, ['line_ids'], context=context):
|
||||
statementLine.unlink(cr, uid, statement['line_ids'], context=context)
|
||||
return super(account_bank_statement, self).unlink(cr, uid, ids, context=context)
|
||||
|
||||
|
||||
account_bank_statement()
|
||||
|
||||
class account_bank_statement_line(osv.osv):
|
||||
|
|
Loading…
Reference in New Issue