Skip to Content
Menu
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
To pytanie dostało ostrzeżenie
1 Odpowiedz
9147 Widoki

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. 

Awatar
Odrzuć
Autor Najlepsza odpowiedź

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

 

Awatar
Odrzuć

Nice! Thanks

Powiązane posty Odpowiedzi Widoki Czynność
1
cze 15
6067
0
mar 15
2673
2
lut 16
7712
0
cze 15
3813
2
mar 15
4594