This question has been flagged
3 Replies
4297 Views

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!

Avatar
Discard
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:
Avatar
Discard
Author

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

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.

Author

it does not, should I add it from there?

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.

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.

Avatar
Discard
Author 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!

Avatar
Discard