Odoo Help

0

How do use a fields.funtion in one object to change one variable depending on a change of state of another object state?

By
Anabela Damas
on 11/14/13, 10:46 AM 681 views

Hi,

I'm trying to do a fields.function in account.voucher.line that when the state of account.voucher change save some information in account.voucher.line. I've started just by saving one thing. But I'm facing some issues. I've done this code:

class account_voucher_line(osv.osv):
    _name = 'account.voucher.line'
    _description = 'Voucher Lines'
    _order = "move_line_id"
    _inherit = "account.voucher.line"



    def _get_invoice(self, cr, uid, ids, field_name, arg, context=None):
        result = {}

        import pdb #stop code to debug
        pdb.set_trace() #stop code to debug 

        #############################################################
        ### In here "ids" is from account.voucher, I need the id from account.voucher.line   #
        #############################################################

        return result    


    _columns = {
        'account_invoice': fields.function(_get_invoice, method=True, type="many2one", relation='account.invoice', store={'account.voucher': (lambda self, cr, uid, ids, ctx={}: ids , ['state'], 10),}, string="Invoice"),
    }

account_voucher_line()

1º : What I'm trying to do is possible? 2º : If so, how do I pass to the function the id(or another field) from account.voucher.line?

Thanks!

About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

Register

Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

0 follower(s)

Stats

Asked: 11/14/13, 10:46 AM
Seen: 681 times
Last updated: 3/16/15, 8:10 AM