diff options
| author | Mustufa Rangwala <mra@tinyerp.com> | 2008-09-17 17:24:22 +0530 |
|---|---|---|
| committer | Mustufa Rangwala <mra@tinyerp.com> | 2008-09-17 17:24:22 +0530 |
| commit | bd17a1e2b00ce451beba2bd1d39d83090e318feb (patch) | |
| tree | 0d7e938f3a34ac9f823a072f907e0a032d7f4e12 | |
| parent | 28d49122f139a2b96fe2431c14d3ef13b3bc4c2c (diff) | |
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
| -rw-r--r-- | addons/account_payment/payment.py | 16 | ||||
| -rw-r--r-- | addons/account_payment/payment_view.xml | 44 |
2 files changed, 36 insertions, 24 deletions
diff --git a/addons/account_payment/payment.py b/addons/account_payment/payment.py index ca1f52f5ebb..c56116aaeab 100644 --- a/addons/account_payment/payment.py +++ b/addons/account_payment/payment.py @@ -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 diff --git a/addons/account_payment/payment_view.xml b/addons/account_payment/payment_view.xml index 102b4eccd10..d77c454a90c 100644 --- a/addons/account_payment/payment_view.xml +++ b/addons/account_payment/payment_view.xml @@ -24,7 +24,7 @@ </record> <menuitem id="menu_main" name="Payment" parent="account.menu_finance"/> - + <record id="view_payment_type_form" model="ir.ui.view"> <field name="name">payment.type.form</field> <field name="model">payment.type</field> @@ -38,7 +38,7 @@ </form> </field> </record> - + <record id="view_payment_mode_tree" model="ir.ui.view"> <field name="name">payment.mode.tree</field> <field name="model">payment.mode</field> @@ -69,9 +69,9 @@ <field name="view_type">form</field> <field name="view_mode">tree,form</field> </record> - + <menuitem id="next_id_44" name="Payment" parent="account.menu_finance_configuration"/><menuitem action="action_payment_mode_form" id="menu_action_payment_mode_form" parent="next_id_44"/> - + <record id="view_payment_order_form" model="ir.ui.view"> <field name="name">payment.order.form</field> <field name="model">payment.order</field> @@ -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"/> @@ -102,14 +102,14 @@ <separator colspan="2" string="Desitination Account"/> <field colspan="2" name="info_owner" nolabel="1"/> <field colspan="2" name="info_partner" nolabel="1"/> - + <field colspan="4" name="communication"/> <field colspan="4" name="communication2"/> <field name="name"/> <field name="state"/> </page> <page string="Information"> - + <separator colspan="4" string="General Information"/> <group colspan="2"> <field name="amount"/> @@ -157,7 +157,7 @@ </form> </field> </record> - + <record id="view_payment_order_tree" model="ir.ui.view"> <field name="name">payment.order.tree</field> <field name="model">payment.order</field> @@ -176,7 +176,7 @@ </tree> </field> </record> - + <record id="action_payment_order_tree" model="ir.actions.act_window"> <field name="name">Payment order</field> <field name="res_model">payment.order</field> @@ -184,7 +184,7 @@ <field name="view_mode">form,tree</field> </record> <menuitem action="action_payment_order_tree" id="menu_action_payment_order_form" parent="account_payment.menu_main" sequence="3"/> - + <record id="action_payment_order_draft" model="ir.actions.act_window"> <field name="name">Draft payment order</field> <field name="res_model">payment.order</field> @@ -193,7 +193,7 @@ <field name="domain">[('state','=','draft')]</field> </record> <menuitem action="action_payment_order_draft" id="menu_action_payment_order_draft" parent="account_payment.menu_action_payment_order_form" sequence="1"/> - + <record id="action_payment_order_open" model="ir.actions.act_window"> <field name="name">Payment orders to validate</field> <field name="res_model">payment.order</field> @@ -202,7 +202,7 @@ <field name="domain">[('state','=','open')]</field> </record> <menuitem action="action_payment_order_open" id="menu_action_payment_order_open" parent="account_payment.menu_action_payment_order_form" sequence="2"/> - + <record id="view_payment_line_form" model="ir.ui.view"> <field name="name">Payment Line</field> <field name="model">payment.line</field> @@ -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"/> @@ -227,14 +227,14 @@ <separator colspan="2" string="Desitination Account"/> <field colspan="2" name="info_owner" nolabel="1"/> <field colspan="2" name="info_partner" nolabel="1"/> - + <field colspan="4" name="communication"/> <field colspan="4" name="communication2"/> <field name="name"/> <field name="state"/> </page> <page string="Information"> - + <separator colspan="4" string="General Information"/> <group colspan="2"> <field name="amount" select="1"/> @@ -268,7 +268,7 @@ <!--<field name="value_date"/>--> <field name="partner_id" select="1"/> <field name="amount" sum="Amount Total"/> - <field name="amount_currency" sum="Currency Amount Total" select="2"/> + <field name="amount_currency" sum="Currency Amount Total" select="2" /> <field name="currency"/> <field name="bank_id" domain="[('partner_id', '=', partner_id)]" required="1"/> <!--<field name="to_pay_currency"/> @@ -284,7 +284,7 @@ <field name="state"/> <field name="date"/>--> <!-- <field invisible="1" name="to_pay_currency"/>--> - + </tree> </field> </record> @@ -294,7 +294,7 @@ <field name="view_type">tree</field> <field name="view_mode">form,tree</field> </record> - + <record id="view_bank_statement_form" model="ir.ui.view"> <field name="name">account.bank.statement.form.inherit</field> <field name="model">account.bank.statement</field> @@ -306,8 +306,8 @@ </group> </field> </record> - + <act_window domain="[('move_line_id.move_id.id', '=', move_id)]" id="act_account_invoice_2_payment_line" name="Payment Lines" res_model="payment.line" src_model="account.invoice"/> - + </data> </openerp> |
