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

onchange_partner_id method of sale_order don't receive partner_id

By
Ruslan Prokopiev
on 11/3/14, 10:35 AM 1,031 views

I'm overriding onchange_partner_id method of sale_order class, and I need partner_id parameter.

 

How can I get it?

here the code:

 

#this works

class account_invoice(osv.osv):
    _inherit = "account.invoice"

    def onchange_partner_id(self, cr, uid, ids, type, partner_id,
                            date_invoice=False, payment_term=False,
                            partner_bank_id=False, company_id=False):
        res = super(account_invoice, self).onchange_partner_id(
            cr, uid, ids, type, partner_id,
            date_invoice=date_invoice, payment_term=payment_term,
            partner_bank_id=partner_bank_id, company_id=company_id)

        partner = self.pool.get('res.partner').browse(cr, uid, partner_id)
        preffered_account = partner.our_preferred_account

        res['value'].update({'partner_bank_id': preffered_account['id']})
        return res

 

# this don't work
class sale_order(osv.osv):
    _inherit = "sale.order"

    def onchange_partner_id(self, cr, uid, ids, part, context=None):
        # I need partner_id here

        # ADD: use part stupid

        res = super(sale_order, self).onchange_partner_id(

            cr, uid, ids, part, context=context)
        partner = self.pool.get('res.partner').browse(cr, uid, partner_id)
        preffered_account = partner.our_preferred_account

        res['value'].update({'partner_bank_id': preffered_account['id']})
        return res

 

ANSWER: Sorry, I was stupid, part is parner_id

Can you share your code here so we can find where is problem ?

Jagdish Panchal
on 11/3/14, 11:45 PM
0

Ben Bernard

--Ben Bernard--
1083
| 4 3 6
Jakarta, Indonesia
--Ben Bernard--
Ben Bernard
On 11/3/14, 11:10 PM

Inherit the xml view.

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

2 follower(s)

Stats

Asked: 11/3/14, 10:35 AM
Seen: 1031 times
Last updated: 3/16/15, 8:10 AM