1
對不起,這是一個初級問題。OpenERP onchange事件從父表中獲取詳細信息
我在OpenERP的下表:
支付表
---------------------------------------------------------------------
| 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 | OR_DATE | TRANS_TYPE |
---------------------------------
| 1 | 2010-10-15 | 1 |
---------------------------------
| 2 | 2010-10-30 | 2 |
---------------------------------
| 3 | 2010-10-15 | 1 |
---------------------------------
付款明細表(子表)
-----------------------------------------
| ID | DESCRIPTION | ACCOUNT_CODE |
-----------------------------------------
| 1 | Cash | ACCCODE001 |
-----------------------------------------
| 2 | Check | ACCCODE002 |
-----------------------------------------
| 3 | Credit Card | ACCCODE003 |
-----------------------------------------
我有2班在OpenERP的結構如下:
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>
如何添加payment_detail
類自動獲取內部的onchange_description
事件並從「付款」表中打印詳細信息?
在此先感謝!
您可以使用編輯器中的'{}'按鈕標記文本代碼的一整塊。這樣它得到很好的格式。 –
你是什麼意思'自動提取和打印來自「付款」表的詳細信息?你的意思是說,當父母(付款)條目發生變化時,你希望'描述'字段自動更新爲某些內容? – jayven
Hi @jayven我的意思是我應該能夠打印來自付款表(ID,OR_DATE,TRANS_TYPE)的詳細信息 – codemickeycode