In openerp, how to access field value of form via wizard

1.2k views Asked by At

This might be silly but i don't have idea.

While we go to Accounting -> Customers -> Customer Invoices(model: account.invoice) there is a field 'Total'(amount_total).

I have added a boolean field in account.voucher.

 'test': fields.boolean('Test'),

Now in wizard(Pay Invoice) which opens on click of button 'Register payment'. I want to make this field visible or unvisible based on value of 'Total'. If the value we fill in 'Paid Amount'(amount) is less than 'Total' then 'test' field should be visible else invisible.

How can i make it possible?

Thanx in advance.

2

There are 2 answers

0
Atul Arvind On

In the account_voucher-> invoice.py file there is a method named invoice_pay_customer.

this is the method is called when the you click on the Register Payment button(enable the debug mode), you just need to update the context value, you just need to override this method like,

def invoice_pay_customer(self, cr, uid, ids, context=None):
    vals = super(invoice, self).invoice_pay_customer(cr, uid, ids, context=None)
    inv = self.browse(cr, uid, ids[0], context=context)
    vals.get('context').update({"default_amount": inv.amount_total})
    return vals

it will set the amount in the popup.

3
user1576199 On

as far i understand after read your question is that you want value of total amount in invoice form ok?

and based on this you want to hide some fields?

for the you can do one things,

add one field total in wizard, which contain value of invoice total,

to get value of the invoice total

overwrite the default_get method

def default_get(self, cr, uid, fields, context=None):

in this metho you will get active_id or active_ids of current invoice from this actiove id you will get invoice total field value and set in wizard total value

hope this help