1

奇妙な理由で機能しない単純なカスタマイズを行おうとしています。

init .py:

import account_voucher_hash

openerp .py

{
"name" : "Hash Voucher",
"version" : "1.1",
"depends" : [
              'base',
              'account_voucher',
            ],
"author" : "me",
"description": """The Module customizes Vouchers""",

'website': 'http://abc.com',
'init_xml': [],
'update_xml': [
    'account_voucher_view_hash.xml',
],
'demo_xml': [],
'installable': True,
'active': False,
}

account_voucher_hash.py

from osv import fields, osv
import netsvc

class account_voucher_hash(osv.osv):
_name = 'account.voucher'
_inherit = 'account.voucher'
_columns={
          'test1': fields.integer('Test 1'),
          'create_uid': fields.many2one('res.users', 'Created By'),
          'creator_name': fields.related("create_uid", "name", type="char", string="Creator Name"),
          'write_uid': fields.many2one('res.users', 'Modified By'),
          'write_name': fields.related("write_uid", "name", type="char", string="Modifier Name"),
          }
account_voucher_hash()  

account_voucher_view_hash.xml

<?xml version="1.0" encoding="utf-8"?>
<openerp>
 <data>

    <record id="view_voucher_form" model="ir.ui.view">
        <field name="name">account_voucher_hash_form</field>
        <field name="model">account.voucher</field>
        <field name="type">form</field>
        <field name="priority" eval="15"/>
        <field name="arch" type="xml">
            <field name="inherit_id" ref="account_voucher.view_voucher_form" />
            <field name="arch" type="xml">
                <field name="reference" select="2" position="after">
                    <field name="test1"/>
                    <field name="create_uid"/>
                    <field name="creator_name"/>
                    <field name="write_uid"/>
                    <field name="write_name"/>
                </field>
            </field>
        </field>
    </record>


  </data>
</openerp>

Journal Voucherフォームには、新しいフィールドは表示されません。どこが間違っているのですか?

4

1 に答える 1

1

.pyからcreate_uidとcreator_nameを削除する必要があります。

_columns = {
    'test1': fields.integer('Test 1'),
    'create_uid': fields.many2one('res.users', 'Created By', readonly=True),
    'creator_name': fields.related("create_uid", "name", type="char", string="Creator Name"),
    'write_uid': fields.many2one('res.users', 'Modified By'),
    'write_name': fields.related("write_uid", "name", type="char", string="Modifier Name"),
}

「create_uid」は読み取り専用である必要があります。

.xmlで次のコードを試してください。

<record id="view_voucher_form" model="ir.ui.view">
    <field name="name">account_voucher_hash_form</field>
    <field name="model">account.voucher</field>
    <field name="type">form</field>
    <field name="priority" eval="15"/>
    <field name="inherit_id" ref="account_voucher.view_voucher_form"/>
    <field name="arch" type="xml">
            <field name="reference" select="2" position="after">
                <field name="test1"/>
                <field name="create_uid"/>
                <field name="creator_name"/>
                <field name="write_uid"/>
                <field name="write_name"/>
            </field>
        </field>
</record>
于 2012-12-06T11:02:19.077 に答える