Odoo Help


How could I detect if a sale.order was created online in onchange_partner_id?

Pascal Tremblay
on 4/8/16, 5:10 PM 452 views

Hello all,

In the sale.order method onchange_partner_id, I would want to attrib a different dedicated_salesman according to the place where the sale order was created (frontend shop or backend).

How to detect if the sale order was created in the frontend public shop or in the backend in this code???

Thanks to help

class sale_order(osv.osv):
    _inherit = "sale.order"
    def onchange_partner_id(self, cr, uid, ids, part, context=None):
        #_logger.error("onchange_partner_id BEGIN")
        if not part:
            return {'value': {'partner_invoice_id': False, 'partner_shipping_id': False,  'payment_term': False, 'fiscal_position': False}}
        part = self.pool.get('res.partner').browse(cr, uid, part, context=context)
        addr = self.pool.get('res.partner').address_get(cr, uid, [part.id], ['delivery', 'invoice', 'contact'])
        pricelist = part.property_product_pricelist and part.property_product_pricelist.id or False
        invoice_part = self.pool.get('res.partner').browse(cr, uid, addr['invoice'], context=context)
        payment_term = invoice_part.property_payment_term and invoice_part.property_payment_term.id or False
        dedicated_salesman = part.user_id and part.user_id.id or uid
        val = {
            'partner_invoice_id': addr['invoice'],
            'partner_shipping_id': addr['delivery'],
            'payment_term': payment_term,
            'user_id': dedicated_salesman,

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


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

1 follower(s)


Asked: 4/8/16, 5:10 PM
Seen: 452 times
Last updated: 4/8/16, 5:10 PM