1

对不起,这是一个初学者的问题。

我在 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 个类,其结构如下:

蟒蛇代码:

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

提前致谢!

4

1 回答 1

5

您可以使用参数。您可以在销售模块中找到一个示例(python 文件

在你的情况下,尝试使用类似的东西

<field name="description" on_change="onchange_description(description, parent.or_date)"/>
于 2012-11-14T07:53:08.360 回答