Odoo Help


Proper syntax for passing the active id to a server action

Fred Meyers
on 7/30/17, 1:21 AM 520 views

Hi all,

The end goal of this action is to programmatically add an order line to a sales order

I have a custom button defined in a sales order view like this:

<button name="401" type="action" class="btn-primary" string="help me"></button>

action id 401 is a server action that I've defined using the "sales.order" base model and the action to do is "execute python code"

The code so far is just this:

values = {
            'order_id': sale.order.id,

I want to pass the current order id (sale.order.id) to the action's code. That way the create() function adds a new line to the current order automatically.

I think it has something to do with contexts, but the documentation is confusing to me. I've been googling all day.


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

2 follower(s)


Asked: 7/30/17, 1:21 AM
Seen: 520 times
Last updated: 3/13/18, 10:17 PM