すみません、初歩的な質問です。
OpenERP に次のテーブルがあります。
支払いテーブル (親テーブル)
---------------------------------
| ID | OR_DATE | TRANS_TYPE |
---------------------------------
| 1 | 2010-10-15 | 1 |
---------------------------------
| 2 | 2010-10-30 | 2 |
---------------------------------
| 3 | 2010-10-15 | 1 |
---------------------------------
支払詳細テーブル (子テーブル)
---------------------------------------------------------------------
| ID | OTH_PYMT_ID | DESCRIPTION | ACCOUNT_TITLE_ID | AMOUNT |
---------------------------------------------------------------------
| 1 | 1 | Cash Payment 1 | 1 | 1,000 |
---------------------------------------------------------------------
| 2 | 1 | Check Payment 1 | 2 | 1,000 |
---------------------------------------------------------------------
| 3 | 2 | Cash Payment 2 | 1 | 1,000 |
---------------------------------------------------------------------
支払種別表(参考表)
-----------------------------------------
| ID | DESCRIPTION | ACCOUNT_CODE |
-----------------------------------------
| 1 | Cash | ACCCODE001 |
-----------------------------------------
| 2 | Check | ACCCODE002 |
-----------------------------------------
| 3 | Credit Card | ACCCODE003 |
-----------------------------------------
OpenERP には、次の構造を持つ 2 つのクラスがあります。
Python コード:
payment(osv.osv):
"""
OpenERP Model : payment
"""
_name = 'payment'
_description = __doc__
_columns = {
'or_date': fields.date('OR Date'),
'trans_type':fields.many2one('payment.type', "Transaction Type"),
'oth_pymt_det_ids':fields.one2many('payment.detail', 'oth_pymt_id', 'Details'),
}
class payment()
class payment_detail(osv.osv):
"""
OpenERP Model : payment_detail
"""
_name = 'payment.detail'
_description = __doc__
#onchange_description function goes here
_columns = {
'oth_pymt_id':fields.many2one('payment', 'Payment'),
'description':fields.char('Description', size=100 ),
'account_title_id':fields.char('Account Title', size=20),
'amount': fields.float('Amount', digits=(16, 2)),
}
payment_detail()
XML コード:
<record model="ir.ui.view" id="payment_form">
<field name="name">Payments</field>
<field name="model">payment</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Payments">
<group col="4" colspan="4">
<field name="trans_type" />
<field name="or_date" />
<field name="oth_pymt_det_ids" mode="tree" nolabel="1" colspan="4">
<tree string="Payment Details" editable="top">
<field name="description" on_change="onchange_description()"/>
<field name="account_title_id"/>
<field name="amount"/>
</tree>
</field>
</group>
</form>
</field>
</record>
「支払い」テーブルから詳細を自動的に取得して出力するonchange_description
イベントをクラス内に追加するにはどうすればよいですか?payment_detail
前もって感謝します!