Odoo Help

Welcome!

This community 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.

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 565 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!

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

0 follower(s)

Stats

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