Přejít na obsah
Menu
You need to be registered to interact with the community.
This question has been flagged
1 Odpovědět
9123 Zobrazení

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. 

Avatar
Zrušit
Autor Nejlepší odpověď

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')]}"/>           	   

 

Avatar
Zrušit

Nice! Thanks

Related Posts Odpovědi Zobrazení Aktivita
1
čvn 15
6050
0
bře 15
2665
2
úno 16
7683
0
čvn 15
3791
2
bře 15
4579