Trợ giúp

0

invalid xml architecture?

Avatar
David Brilliant

I've been wrangling with this annoying bug for a week. Its really hacking me off.

I'm trying to inherit the Account_Voucher class, and modify the existing wizard with a few extra buttons so our sales guys can validate credit cards before accepting payment. code follows:

<?xml version="1.0" encoding="utf-8"?>
<openerp>
    <data>
    <record id="novak_custom_payment_view" model="ir.ui.view">
        <field name="name">account.voucher.novak</field>
        <field name="model">account.voucher</field>
        <field name="inherit_id" ref="account_voucher.view_vendor_receipt_dialog_form" />
            <field name="arch" type="xml">
                <field name="journal_id" position="after">
                <field name="card_number" string="card number" />
            </field>
        </field>
    </record>
    </data>
</openerp>

Removing the Inherit_id field allows the module to install, but fails to insert the fields after the journal_id field.

Help! I'm on a work deadline!

Ảnh đại diện
Huỷ bỏ
3 Câu trả lời
0
Avatar
Ray Carnes
Best Answer

Does your module depend on account_voucher?

UPDATE: Code snippet:

# -*- coding: utf-8 -*- 

from openerp.osv import fields, osv

class custom_account_voucher(osv.osv):

    _inherit = 'account.voucher'

    _columns = {
        'card_number':fields.char('Card Number', size=16, readonly=True, 
                                   states={'draft':[('readonly',False)]}),
    }

# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
4 Bình luận
Ảnh đại diện
Huỷ bỏ
Avatar
David Brilliant
-

from the __openerp__.py: 'depends': ['base','account_voucher'],

Avatar
Ray Carnes
-

Comment out the record tag and install your module. Is card_number shown in Settings --> Technical --> Database Structure --> Models when you look at the list of fields for the account.voucher model.

Avatar
David Brilliant
-

it does not, should I add it from there?

Avatar
Ray Carnes
-

If the model is not showing your field, then it hasn't been defined properly (or at all) in your custom python class. If you add it via the database UI, it will only be available in that database. It would be better to create the field via python. I've edited my answer to provide a code snippet.

0
Avatar
David Brilliant
Best Answer

I needed to create the database entries in the _columns variable, so the solution was to make a .py file and insert the following:

_columns={'card_number']: fields.char('credit card number', size=256, help="CC Number")}

Thanks ray and crew!

Ảnh đại diện
Huỷ bỏ
0
Avatar
Keyur
Best Answer

Hi David,

I think the problem is in view architecture.

There are total two </field> & </field> tags which are closed. You just have to remove one of them (</field>) & then it will work.

Ảnh đại diện
Huỷ bỏ