This commit is contained in:
unknown
2013-04-10 13:25:50 +02:00
parent 8c16725ecb
commit 17f2c78065
2 changed files with 47 additions and 34 deletions

View File

@@ -25,11 +25,9 @@
'maintainer': 'Camptocamp', 'maintainer': 'Camptocamp',
'category': 'Finance', 'category': 'Finance',
'complexity': 'normal', 'complexity': 'normal',
'depends': [ 'depends': ['account',
'account',
'report_webkit', 'report_webkit',
'account_voucher' 'account_voucher'],
],
'description': """ 'description': """
Improve the basic bank statement, by adding various new features, Improve the basic bank statement, by adding various new features,
and help dealing with huge volume of reconciliation through payment offices such as Paypal, Lazer, and help dealing with huge volume of reconciliation through payment offices such as Paypal, Lazer,
@@ -87,4 +85,4 @@
'auto_install': False, 'auto_install': False,
'license': 'AGPL-3', 'license': 'AGPL-3',
'active': False, 'active': False,
} }

View File

@@ -18,7 +18,6 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
# #
############################################################################## ##############################################################################
from openerp.osv.orm import Model from openerp.osv.orm import Model
from openerp.osv import fields, osv from openerp.osv import fields, osv
from openerp.tools.translate import _ from openerp.tools.translate import _
@@ -44,38 +43,45 @@ class AccountStatementProfil(Model):
"commission move (and optionaly on the counterpart " "commission move (and optionaly on the counterpart "
"of the intermediate/banking move if you tick the " "of the intermediate/banking move if you tick the "
"corresponding checkbox)."), "corresponding checkbox)."),
'journal_id': fields.many2one( 'journal_id': fields.many2one(
'account.journal', 'account.journal',
'Financial journal to use for transaction', 'Financial journal to use for transaction',
required=True), required=True),
'commission_account_id': fields.many2one( 'commission_account_id': fields.many2one(
'account.account', 'account.account',
'Commission account', 'Commission account',
required=True), required=True),
'commission_analytic_id': fields.many2one( 'commission_analytic_id': fields.many2one(
'account.analytic.account', 'account.analytic.account',
'Commission analytic account'), 'Commission analytic account'),
'receivable_account_id': fields.many2one( 'receivable_account_id': fields.many2one(
'account.account', 'account.account',
'Force Receivable/Payable Account', 'Force Receivable/Payable Account',
help="Choose a receivable account to force the default " help="Choose a receivable account to force the default "
"debit/credit account (eg. an intermediat bank account " "debit/credit account (eg. an intermediat bank account "
"instead of default debitors)."), "instead of default debitors)."),
'force_partner_on_bank': fields.boolean( 'force_partner_on_bank': fields.boolean(
'Force partner on bank move', 'Force partner on bank move',
help="Tick that box if you want to use the credit " help="Tick that box if you want to use the credit "
"institute partner in the counterpart of the " "institute partner in the counterpart of the "
"intermediate/banking move."), "intermediate/banking move."),
'balance_check': fields.boolean( 'balance_check': fields.boolean(
'Balance check', 'Balance check',
help="Tick that box if you want OpenERP to control " help="Tick that box if you want OpenERP to control "
"the start/end balance before confirming a bank statement. " "the start/end balance before confirming a bank statement. "
"If don't ticked, no balance control will be done." "If don't ticked, no balance control will be done."),
),
'bank_statement_prefix': fields.char( 'bank_statement_prefix': fields.char('Bank Statement Prefix', size=32),
'Bank Statement Prefix', size=32),
'bank_statement_ids': fields.one2many( 'bank_statement_ids': fields.one2many('account.bank.statement',
'account.bank.statement', 'profile_id', 'Bank Statement Imported'), 'profile_id',
'Bank Statement Imported'),
# TODO # TODO
# 'how_get_type_account': fields.selection( # 'how_get_type_account': fields.selection(
# [ ('amount', 'Based on amount and partner type'), # [ ('amount', 'Based on amount and partner type'),
@@ -264,8 +270,10 @@ class AccountBankSatement(Model):
create the move from. create the move from.
:return: int/long of the res.partner to use as counterpart :return: int/long of the res.partner to use as counterpart
""" """
bank_partner_id = super(AccountBankSatement, self).\ bank_partner_id = super(AccountBankSatement, self)._get_counter_part_partner(cr,
_get_counter_part_partner(cr, uid, st_line, context=context) uid,
st_line, c
ontext=context)
# get the right partner according to the chosen profil # get the right partner according to the chosen profil
if st_line.statement_id.profile_id.force_partner_on_bank: if st_line.statement_id.profile_id.force_partner_on_bank:
bank_partner_id = st_line.statement_id.profile_id.partner_id.id bank_partner_id = st_line.statement_id.profile_id.partner_id.id
@@ -337,11 +345,15 @@ class AccountBankSatement(Model):
if st_line.analytic_account_id: if st_line.analytic_account_id:
if not st.journal_id.analytic_journal_id: if not st.journal_id.analytic_journal_id:
raise osv.except_osv(_('No Analytic Journal !'), raise osv.except_osv(_('No Analytic Journal !'),
_("You have to assign an analytic journal on the '%s' journal!") % (st.journal_id.name,)) _("You have to assign an analytic"
" journal on the '%s' journal!") % (st.journal_id.name,))
if not st_line.amount: if not st_line.amount:
continue continue
st_line_number = self.get_next_st_line_number(cr, uid, st_number, st_line, context) st_line_number = self.get_next_st_line_number(cr, uid, st_number, st_line, context)
self.create_move_from_st_line(cr, uid, st_line.id, company_currency_id, st_line_number, context) self.create_move_from_st_line(cr, uid, st_line.id,
company_currency_id,
st_line_number,
context)
except osv.except_osv, exc: except osv.except_osv, exc:
msg = "Line ID %s with ref %s had following error: %s" % (st_line.id, st_line.ref, exc.value) msg = "Line ID %s with ref %s had following error: %s" % (st_line.id, st_line.ref, exc.value)
errors_stack.append(msg) errors_stack.append(msg)
@@ -352,16 +364,19 @@ class AccountBankSatement(Model):
msg = u"\n".join(errors_stack) msg = u"\n".join(errors_stack)
raise osv.except_osv(_('Error'), msg) raise osv.except_osv(_('Error'), msg)
#end changes #end changes
self.write(cr, uid, [st.id], { self.write(cr, uid, [st.id],
'name': st_number, {'name': st_number,
'balance_end_real': st.balance_end 'balance_end_real': st.balance_end},
}, context=context) context=context)
self.message_post(cr, uid, [st.id], body=_('Statement %s confirmed, journal items were created.') % (st_number,), context=context) self.message_post(cr, uid, [st.id], b
ody=_('Statement %s confirmed, journal items were created.') % (st_number,),
context=context)
return self.write(cr, uid, ids, {'state': 'confirm'}, context=context) return self.write(cr, uid, ids, {'state': 'confirm'}, context=context)
def get_account_for_counterpart(self, cr, uid, amount, account_receivable, account_payable): def get_account_for_counterpart(self, cr, uid, amount, account_receivable, account_payable):
"""For backward compatibility.""" """For backward compatibility."""
account_id, type = self.get_account_and_type_for_counterpart(cr, uid, amount, account_receivable, account_id, type = self.get_account_and_type_for_counterpart(cr, uid, amount,
account_receivable,
account_payable) account_payable)
return account_id return account_id
@@ -385,9 +400,9 @@ class AccountBankSatement(Model):
type = 'supplier' type = 'supplier'
if partner_id: if partner_id:
part = obj_partner.browse(cr, uid, partner_id, context=context) part = obj_partner.browse(cr, uid, partner_id, context=context)
if part.supplier == True: if part.supplier:
type = 'supplier' type = 'supplier'
elif part.customer == True: elif part.customer:
type = 'customer' type = 'customer'
return type return type