mirror of
https://github.com/OCA/account-financial-tools.git
synced 2025-02-02 12:47:26 +02:00
[IMP]account_check_deposit: add the print option webkit
This commit is contained in:
committed by
Sebastien Beau
parent
6df43c453f
commit
f705a6b026
@@ -3,6 +3,7 @@
|
||||
# #
|
||||
# account_check_deposit for OpenERP #
|
||||
# Copyright (C) 2012 Akretion Benoît GUILLOT <benoit.guillot@akretion.com> #
|
||||
# Copyright (C) 2013 Akretion Chafique DELLI <chafique.delli@akretion.com> #
|
||||
# #
|
||||
# This program is free software: you can redistribute it and/or modify #
|
||||
# it under the terms of the GNU Affero General Public License as #
|
||||
@@ -32,7 +33,7 @@
|
||||
You may have to create an account for recieved checks and a journal for payment by checks.""",
|
||||
'author': 'Akretion',
|
||||
'website': 'http://www.akretion.com/',
|
||||
'depends': ['account_accountant'],
|
||||
'depends': ['account_accountant','report_webkit'],
|
||||
'init_xml': [],
|
||||
'update_xml': [
|
||||
'account_deposit_view.xml',
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
# #
|
||||
# account_check_deposit for OpenERP #
|
||||
# Copyright (C) 2012 Akretion Benoît GUILLOT <benoit.guillot@akretion.com> #
|
||||
# Copyright (C) 2013 Akretion Chafique DELLI <chafique.delli@akretion.com> #
|
||||
# #
|
||||
# This program is free software: you can redistribute it and/or modify #
|
||||
# it under the terms of the GNU Affero General Public License as #
|
||||
@@ -27,6 +28,16 @@ class account_check_deposit(Model):
|
||||
_name = "account.check.deposit"
|
||||
_description = "Account Check Deposit"
|
||||
|
||||
def sum_amount(self, cr, uid, ids, name, args, context=None):
|
||||
res = {}
|
||||
total = 0
|
||||
for deposit in self.browse(cr, uid, ids, context=context):
|
||||
for line in deposit.check_payment_ids:
|
||||
total += line.debit
|
||||
res[deposit.id]= total
|
||||
return res
|
||||
|
||||
|
||||
_columns = {
|
||||
'name': fields.char('Name', size=64, required=True, readonly=True, states={'draft':[('readonly',False)]}),
|
||||
'check_payment_ids': fields.many2many('account.move.line', 'account_move_line_deposit_rel',
|
||||
@@ -42,14 +53,17 @@ class account_check_deposit(Model):
|
||||
],'Status', readonly=True),
|
||||
'move_id': fields.many2one('account.move', 'Journal Entry', readonly=True,
|
||||
states={'draft':[('readonly',False)]}),
|
||||
'total_amount': fields.function(sum_amount, string ="total amount"),
|
||||
}
|
||||
|
||||
|
||||
_defaults = {
|
||||
'name': lambda self, cr, uid, context: '/',
|
||||
'deposit_date': fields.date.context_today,
|
||||
'state':'draft',
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
def cancel(self, cr, uid, ids, context=None):
|
||||
for deposit in self.browse(cr, uid, ids, context=context):
|
||||
if not deposit.journal_id.update_posted:
|
||||
@@ -59,23 +73,23 @@ class account_check_deposit(Model):
|
||||
deposit.move_id.button_cancel()
|
||||
deposit.move_id.unlink()
|
||||
return True
|
||||
|
||||
|
||||
def create(self, cr, uid, vals, context=None):
|
||||
if vals.get('name','/')=='/':
|
||||
vals['name'] = self.pool.get('ir.sequence').get(cr, uid, 'account.check.deposit') or '/'
|
||||
return super(account_check_deposit, self).create(cr, uid, vals, context=context)
|
||||
|
||||
|
||||
def _prepare_account_move_vals(self, cr, uid, deposit, context=None):
|
||||
move_vals = {}
|
||||
move_lines = [[0, 0, self._prepare_sum_move_line_vals(cr, uid, deposit, move_vals, context=context)]]
|
||||
for line in deposit.check_payment_ids:
|
||||
move_lines.append([0, 0, self._prepare_move_line_vals(cr, uid, line, move_vals, context=context)])
|
||||
move_lines.append([0, 0, self._prepare_move_line_vals(cr, uid, line, move_vals, context=context)])
|
||||
move_vals.update({
|
||||
'journal_id': deposit.journal_id.id,
|
||||
'line_id': move_lines,
|
||||
})
|
||||
return move_vals
|
||||
|
||||
|
||||
def _prepare_move_line_vals(self, cr, uid, line, move_vals, context=None):
|
||||
move_line_vals = self.pool.get('account.move.line').default_get(cr, uid,
|
||||
['centralisation', 'date','date_created',
|
||||
@@ -83,20 +97,21 @@ class account_check_deposit(Model):
|
||||
'account_id', 'period_id', 'company_id'],
|
||||
context=context)
|
||||
move_line_vals.update({
|
||||
'name': line.ref, #name ?
|
||||
'name': line.name,
|
||||
'credit': line.debit,
|
||||
'account_id': line.account_id.id,
|
||||
'partner_id': line.partner_id.id,
|
||||
'ref': line.ref,
|
||||
})
|
||||
return move_line_vals
|
||||
|
||||
|
||||
def _prepare_sum_move_line_vals(self, cr, uid, deposit, move_vals, context=None):
|
||||
move_line_vals = self.pool.get('account.move.line').default_get(cr, uid,
|
||||
['centralisation', 'date','date_created',
|
||||
'currency_id', 'journal_id', 'amount_currency',
|
||||
'account_id', 'period_id', 'company_id', 'state'],
|
||||
context=context)
|
||||
|
||||
debit = 0.0
|
||||
for line in deposit.check_payment_ids:
|
||||
debit += line.debit
|
||||
@@ -105,9 +120,9 @@ class account_check_deposit(Model):
|
||||
'debit': debit,
|
||||
'ref': deposit.name,
|
||||
})
|
||||
|
||||
|
||||
return move_line_vals
|
||||
|
||||
|
||||
def _reconcile_checks(self, cr, uid, deposit, move_id, context=None):
|
||||
move_line_obj = self.pool.get('account.move.line')
|
||||
for line in deposit.check_payment_ids:
|
||||
@@ -117,7 +132,7 @@ class account_check_deposit(Model):
|
||||
if move_line_ids:
|
||||
move_line_obj.reconcile(cr, uid, [line.id, move_line_ids[0]], context=context)
|
||||
return True
|
||||
|
||||
|
||||
def validate_deposit(self, cr, uid, ids, context=None):
|
||||
move_obj = self.pool.get('account.move')
|
||||
if context is None:
|
||||
@@ -125,15 +140,17 @@ class account_check_deposit(Model):
|
||||
for deposit in self.browse(cr, uid, ids, context=context):
|
||||
context['journal_id'] = deposit.journal_id.id
|
||||
move_vals = self._prepare_account_move_vals(cr, uid, deposit, context=context)
|
||||
print "move_vals ====>", move_vals
|
||||
move_id = move_obj.create(cr, uid, move_vals, context=context)
|
||||
move_obj.post(cr, uid, [move_id], context=context)
|
||||
self._reconcile_checks(cr, uid, deposit, move_id, context=context)
|
||||
deposit.write({'state':'done', 'move_id': move_id})
|
||||
return True
|
||||
|
||||
|
||||
|
||||
class account_move_line(Model):
|
||||
_inherit = "account.move.line"
|
||||
|
||||
|
||||
_columns = {
|
||||
'check_deposit_id': fields.many2many('account.check.deposit', 'account_move_line_deposit_rel',
|
||||
'check_deposit_id', 'move_line_id', 'Check Deposit'),
|
||||
|
||||
@@ -2,12 +2,21 @@
|
||||
<!--
|
||||
account_check_deposit for OpenERP
|
||||
Copyright (C) 2012 Akretion Benoît GUILLOT <benoit.guillot@akretion.com>
|
||||
Copyright (C) 2013 Akretion Chafique DELLI <chafique.delli@akretion.com>
|
||||
The licence is in the file __openerp__.py
|
||||
-->
|
||||
|
||||
<openerp>
|
||||
<data>
|
||||
|
||||
<report
|
||||
auto="False"
|
||||
file="account_check_deposit/report/check_deposit.mako"
|
||||
id="check_deposit_webkit"
|
||||
model="account.check.deposit"
|
||||
name="check.deposit.webkit"
|
||||
report_type="webkit"
|
||||
string="WebKit Check Deposit"/>
|
||||
|
||||
<!-- INHERITED VIEW FOR THE OBJECT : account_check_deposit -->
|
||||
|
||||
<record id="account_check_deposit_view_form" model="ir.ui.view">
|
||||
|
||||
Reference in New Issue
Block a user