[IMP] Account: Onchange of partner on bank statement lines now dont fill amount on line
bzr revid: mra@mra-laptop-20100814053743-fsqvt4ic4mjsor46
This commit is contained in:
parent
79f55cfee7
commit
10794f74d2
|
@ -20,9 +20,9 @@
|
|||
##############################################################################
|
||||
|
||||
import time
|
||||
|
||||
import netsvc
|
||||
from osv import fields, osv
|
||||
|
||||
from tools.misc import currency
|
||||
from tools.translate import _
|
||||
import decimal_precision as dp
|
||||
|
@ -610,45 +610,22 @@ account_bank_statement_reconcile_line()
|
|||
|
||||
class account_bank_statement_line(osv.osv):
|
||||
|
||||
def onchange_partner_id(self, cursor, user, line_id, partner_id, type, currency_id, context={}):
|
||||
def onchange_partner_id(self, cursor, user, line_id, partner_id, type, currency_id, context=None):
|
||||
res = {'value': {}}
|
||||
|
||||
obj_partner = self.pool.get('res.partner')
|
||||
if context is None:
|
||||
context = {}
|
||||
if not partner_id:
|
||||
return res
|
||||
line = self.browse(cursor, user, line_id)
|
||||
|
||||
line = self.browse(cursor, user, line_id)
|
||||
if not line or (line and not line[0].account_id):
|
||||
part = self.pool.get('res.partner').browse(cursor, user, partner_id,
|
||||
context=context)
|
||||
part = obj_partner.browse(cursor, user, 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 not line or (line and not line[0].amount):
|
||||
res_users_obj = self.pool.get('res.users')
|
||||
res_currency_obj = self.pool.get('res.currency')
|
||||
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
|
||||
|
||||
if context.get('amount', 0) > 0:
|
||||
res['value']['amount'] = context.get('amount')
|
||||
|
||||
return res
|
||||
|
||||
def _reconcile_amount(self, cursor, user, ids, name, args, context=None):
|
||||
|
@ -707,7 +684,4 @@ class account_bank_statement_line(osv.osv):
|
|||
|
||||
account_bank_statement_line()
|
||||
|
||||
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
|
||||
|
|
Loading…
Reference in New Issue