Skip ke Konten
Menu
Pertanyaan ini telah diberikan tanda
3 Replies
5661 Tampilan

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
Buang
Jawaban Terbai

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
Buang
Penulis

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.

Penulis

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.

Jawaban Terbai

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
Buang
Penulis Jawaban Terbai

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
Buang
Post Terkait Replies Tampilan Aktivitas
1
Mar 15
4947
2
Mar 15
8869
4
Nov 15
5803
1
Mar 15
5950
2
Mar 15
5378