[FIX] account, bank/cash statement: fixed a bug on account.move numbering when created from account.bank.statement

[IMP] account, bank/cash statement: replaced onchange_patrner_id with onchange_type: we don't want to change the amount automatically anymore
[IMP] account, bank/cash statement: usability improvements

bzr revid: qdp-launchpad@tinyerp.com-20101026161652-ynwwunbspigqfsfc
This commit is contained in:
qdp-launchpad@tinyerp.com 2010-10-26 18:16:52 +02:00
parent 0b8f9e27fe
commit 02d922e395
2 changed files with 27 additions and 46 deletions

View File

@ -43,8 +43,7 @@ class account_bank_statement(osv.osv):
seq = 0
for line in statement.line_ids:
seq += 1
if not line.sequence:
account_bank_statement_line_obj.write(cr, uid, [line.id], {'sequence': seq}, context=context)
account_bank_statement_line_obj.write(cr, uid, [line.id], {'sequence': seq}, context=context)
return res
def button_import_invoice(self, cr, uid, ids, context=None):
@ -319,7 +318,7 @@ class account_bank_statement(osv.osv):
return move_id
def get_next_st_line_number(self, cr, uid, st_number, st_line, context=None):
return st_number + ' - ' + str(st_line.sequence)
return st_number + '/' + str(st_line.sequence)
def balance_check(self, cr, uid, st_id, journal_type='bank', context=None):
st = self.browse(cr, uid, st_id, context)
@ -426,7 +425,7 @@ account_bank_statement()
class account_bank_statement_line(osv.osv):
def onchange_partner_id(self, cursor, user, line_id, partner_id, type, currency_id, context=None):
def onchange_type(self, cr, uid, line_id, partner_id, type, context=None):
res_users_obj = self.pool.get('res.users')
res_currency_obj = self.pool.get('res.currency')
res = {'value': {}}
@ -436,39 +435,21 @@ class account_bank_statement_line(osv.osv):
if not partner_id:
return res
account_id = False
line = self.browse(cursor, user, line_id)
line = self.browse(cr, uid, line_id)
if not line or (line and not line[0].account_id):
part = obj_partner.browse(cursor, user, partner_id, context=context)
part = obj_partner.browse(cr, uid, partner_id, context=context)
if type == 'supplier':
account_id = part.property_account_payable.id
else:
account_id = part.property_account_receivable.id
res['value']['account_id'] = account_id
if account_id and (not line or (line and not line[0].amount)) and not context.get('amount', False):
company_currency_id = res_users_obj.browse(cursor, user, user,
context=context).company_id.currency_id.id
if not currency_id:
currency_id = company_currency_id
cursor.execute('SELECT sum(debit-credit) \
FROM account_move_line \
WHERE (reconcile_id is null) \
AND partner_id = %s \
AND account_id=%s', (partner_id, account_id))
pgres = cursor.fetchone()
balance = pgres and pgres[0] or 0.0
balance = res_currency_obj.compute(cursor, user, company_currency_id,
currency_id, balance, context=context)
res['value']['amount'] = balance
return res
_order = "statement_id desc, sequence"
_name = "account.bank.statement.line"
_description = "Bank Statement Line"
_columns = {
'name': fields.char('Name', size=64, required=True),
'name': fields.char('Communication', size=64, required=True),
'date': fields.date('Date', required=True),
'amount': fields.float('Amount'),
'type': fields.selection([
@ -498,4 +479,4 @@ class account_bank_statement_line(osv.osv):
account_bank_statement_line()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -555,12 +555,12 @@
<page string="Transaction" name="statement_line_ids">
<field colspan="4" name="line_ids" nolabel="1">
<tree editable="bottom" string="Statement lines">
<field name="sequence" readonly="1"/>
<field name="date"/>
<field name="ref"/>
<field name="sequence" readonly="1" invisible="1"/>
<field name="date" groups="base.group_extended"/>
<field name="name"/>
<field name="type"/>
<field name="partner_id" on_change="onchange_partner_id(partner_id, type, parent.currency, {'amount': amount})"/>
<field name="ref"/>
<field name="partner_id" on_change="onchange_type(partner_id, type)"/>
<field name="type" on_change="onchange_type(partner_id, type)"/>
<field domain="[('journal_id','=',parent.journal_id)]" name="account_id"/>
<field name="analytic_account_id" groups="analytic.group_analytic_accounting" domain="[('company_id', '=', parent.company_id), ('type', '&lt;&gt;', 'view')]"/>
<field name="amount"/>
@ -568,8 +568,8 @@
<form string="Statement lines">
<field name="date"/>
<field name="name"/>
<field name="type"/>
<field name="partner_id" on_change="onchange_partner_id(partner_id, type, parent.currency, {'amount': amount})"/>
<field name="type" on_change="onchange_type(partner_id, type)"/>
<field name="partner_id" on_change="onchange_type(partner_id, type)"/>
<field domain="[('journal_id', '=', parent.journal_id), ('type', '&lt;&gt;', 'view')]" name="account_id"/>
<field name="analytic_account_id" groups="analytic.group_analytic_accounting" domain="[('company_id', '=', parent.company_id), ('type', '&lt;&gt;', 'view')]"/>
<field name="amount"/>
@ -1511,8 +1511,8 @@
<tree editable="bottom" string="Statement lines">
<field name="date"/>
<field name="name"/>
<field name="type"/>
<field name="partner_id" on_change="onchange_partner_id(partner_id, type, parent.currency)"/>
<field name="type" on_change="onchange_type(partner_id, type)"/>
<field name="partner_id" on_change="onchange_type(partner_id, type)"/>
<field domain="[('journal_id', '=', parent.journal_id)]" name="account_id"/>
<field name="amount"/>
<field context="{'partner_id': partner_id, 'amount': amount, 'account_id': account_id, 'date':date}" name="reconcile_id"/>
@ -1520,8 +1520,8 @@
<form string="Statement lines">
<field name="date"/>
<field name="name"/>
<field name="type"/>
<field name="partner_id" on_change="onchange_partner_id(partner_id, type, parent.currency)"/>
<field name="type" on_change="onchange_type(partner_id, type)"/>
<field name="partner_id" on_change="onchange_type(partner_id, type)"/>
<field domain="[('journal_id', '=', parent.journal_id)]" name="account_id"/>
<field name="analytic_account_id" groups="analytic.group_analytic_accounting" />
<field name="amount"/>
@ -2591,23 +2591,23 @@ action = self.pool.get('res.config').next(cr, uid, [], context)
<page string="Cash Transactions" attrs="{'invisible': [('state','=','draft')]}">
<field colspan="4" name="line_ids" nolabel="1">
<tree editable="bottom" string="Statement lines">
<field name="sequence"/>
<field name="date"/>
<field name="ref"/>
<field name="sequence" invisible="1"/>
<field name="date" groups="base.group_extended"/>
<field name="name"/>
<field name="type"/>
<field name="partner_id" on_change="onchange_partner_id(partner_id, type, parent.currency, {'amount': amount})"/>
<field name="ref"/>
<field name="partner_id" on_change="onchange_type(partner_id, type)"/>
<field name="type" on_change="onchange_type(partner_id, type)"/>
<field domain="[('journal_id','=',parent.journal_id)]" name="account_id"/>
<field name="analytic_account_id" groups="base.group_extended" />
<field name="analytic_account_id" groups="analytic.group_analytic_accounting" />
<field name="amount"/>
</tree>
<form string="Statement lines">
<field name="date"/>
<field name="name"/>
<field name="type"/>
<field name="partner_id" on_change="onchange_partner_id(partner_id, type, parent.currency)"/>
<field name="type" on_change="onchange_type(partner_id, type)"/>
<field name="partner_id" on_change="onchange_type(partner_id, type)"/>
<field domain="[('journal_id', '=', parent.journal_id), ('type', '&lt;&gt;', 'view')]" name="account_id"/>
<field name="analytic_account_id" groups="base.group_extended" />
<field name="analytic_account_id" groups="analytic.group_analytic_accounting" />
<field name="amount"/>
<field name="ref"/>
<field name="sequence"/>