account payment: payment lines on payment order
-*adding an onchange on amount (first tab) in order to have the amount_currency that is automaticlly computed *moreover, calling this onchange on the onchange of move_line_id bzr revid: mra@tinyerp.com-20080917115422-vwwyywm7oou3diot
This commit is contained in:
parent
28d49122f1
commit
bd17a1e2b0
|
@ -430,12 +430,15 @@ class payment_line(osv.osv):
|
|||
('name_uniq', 'UNIQUE(name)', 'The payment line name must be unique!'),
|
||||
]
|
||||
|
||||
def onchange_move_line(self,cr,uid,ids,move_line_id,payment_type,date_prefered,date_planned,context=None):
|
||||
def onchange_move_line(self,cr,uid,ids,move_line_id,payment_type,date_prefered,date_planned,currency=False,company_currency=False,context=None):
|
||||
data={}
|
||||
data['amount_currency']=data['currency']=data['communication']=data['partner_id']=data['reference']=data['date_created']=data['bank_id']=False
|
||||
data['amount_currency']=data['currency']=data['communication']=data['partner_id']=data['reference']=data['date_created']=data['bank_id']=data['amount']=False
|
||||
if move_line_id:
|
||||
line = self.pool.get('account.move.line').browse(cr,uid,move_line_id)
|
||||
data['amount_currency']=line.amount_to_pay
|
||||
res = self.onchange_amount(cr, uid, ids, data['amount_currency'], currency, company_currency, context)
|
||||
if res:
|
||||
data['amount'] = res['value']['amount']
|
||||
data['partner_id']=line.partner_id.id
|
||||
data['currency']=line.currency_id and line.currency_id.id or False
|
||||
if not data['currency']:
|
||||
|
@ -458,6 +461,15 @@ class payment_line(osv.osv):
|
|||
|
||||
return {'value': data}
|
||||
|
||||
def onchange_amount(self,cr,uid,ids,amount,currency,cmpny_currency,context=None):
|
||||
if not amount:
|
||||
return {}
|
||||
res = {}
|
||||
currency_obj = self.pool.get('res.currency')
|
||||
company_amount = currency_obj.compute(cr, uid, currency, cmpny_currency,amount)
|
||||
res['amount'] = company_amount
|
||||
return {'value': res}
|
||||
|
||||
def onchange_partner(self,cr,uid,ids,partner_id,payment_type,context=None):
|
||||
data={}
|
||||
data['info_partner']=data['bank_id']=False
|
||||
|
|
|
@ -88,12 +88,12 @@
|
|||
<form string="Payment Line">
|
||||
<notebook>
|
||||
<page string="Payment">
|
||||
<field name="move_line_id" on_change="onchange_move_line(move_line_id,parent.mode,parent.date_prefered,parent.date_planned)" select="1"/>
|
||||
<field name="move_line_id" on_change="onchange_move_line(move_line_id,parent.mode,parent.date_prefered,parent.date_planned,currency,company_currency)" select="1"/>
|
||||
<!--domain="[('reconcile_id','=', False), ('credit', '>',0),('amount_to_pay','>',0)] "/>-->
|
||||
<separator colspan="4" string="Transaction Information"/>
|
||||
<field name="date"/>
|
||||
<group colspan="2">
|
||||
<field name="amount_currency" select="2"/>
|
||||
<field name="amount_currency" select="2" on_change="onchange_amount(amount_currency,currency,company_currency)"/>
|
||||
<field name="currency" nolabel="1"/>
|
||||
</group>
|
||||
<field name="partner_id" on_change="onchange_partner(partner_id,parent.mode)" select="1"/>
|
||||
|
@ -213,12 +213,12 @@
|
|||
<page string="Payment">
|
||||
<field name="order_id" select="1"/>
|
||||
<!--<field name="reference" />-->
|
||||
<field name="move_line_id" on_change="onchange_move_line(move_line_id,parent.mode)" select="1"/>
|
||||
<field name="move_line_id" on_change="onchange_move_line(move_line_id,parent.mode,currency,company_currency)" select="1"/>
|
||||
<!--domain="[('reconcile_id','=', False), ('credit', '>',0),('amount_to_pay','>',0)] "/>-->
|
||||
<separator colspan="4" string="Transaction Information"/>
|
||||
<field name="date"/>
|
||||
<group colspan="2">
|
||||
<field name="amount_currency" select="2"/>
|
||||
<field name="amount_currency" select="2" on_change="onchange_amount(amount_currency,currency,comapny_currency)"/>
|
||||
<field name="currency" nolabel="1"/>
|
||||
</group>
|
||||
<field name="partner_id" on_change="onchange_partner(partner_id)" select="1"/>
|
||||
|
|
Loading…
Reference in New Issue