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

[V8][SOLVED]Call server actions with button using name and not ID?

By
FEDERICO LEONI
on 7/3/15, 6:10 PM 624 views

I would like to call my server actions by name and not by id. 

Rest_av, id 640, for example:

 <button name="640" string="Avançar" type="action"/>

Id obviously works fine, I've tried with 

<button name="%(Rest_av)d" string="Avançar" type="action"/>
<button name="Rest_av" string="Avançar" type="action"/>

But is not working. What is the correct syntax? 

If is not possible (but it should be) I would like to create my server actions with predetermined id numbers. 

1
FEDERICO LEONI
On 7/3/15, 6:29 PM

Ok. Looking more deeply on the documentation I found the solution. Is not possible since my server actions are obviously type action.

For the sake of knowledge, from Odoo doc:

type
type of button, indicates how it clicking it affects Odoo:
workflow (default)
sends a signal to a workflow. The button's name is the workflow signal, the row's record is passed as argument to the signal
object
call a method on the list's model. The button's name is the method, which is called with the current row's record id and the current context.
action
load an execute an ir.actions, the button's name is the database id of the action. The context is expanded with the list's model (as active_model), the current row's record (active_id) and all the records currently loaded in the list (active_ids, may be just a subset of the database records matching the current search)

But there is a solution:

The problem is how do you create a server action: if you create it by GUI then you don't have an external ID but just an ID number, while if you create via XML you can use the ID name as a button name and Odoo will assign automatically an ID number.

Example:

I have a server action called rest_checkout_send, then on button name I wrote

<button name="%(rest_checkout_send)d" string="Enviar" type="action" attrs="{'invisible':[('status','=','1')]}"/> 

and it was automatically update in

<button name="723" string="Enviar" type="action" attrs="{'invisible':[('status','=','1')]}"/>           	   

 

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

1 follower(s)

Stats

Asked: 7/3/15, 6:10 PM
Seen: 624 times
Last updated: 7/23/15, 3:52 PM