Odoo Help

0

Create window action button using XML ID

By
Michael Leff
on 12/30/16, 9:27 PM 3,783 views

In an Odoo view, I can create a button to trigger a specific window action by giving the button a name equal to the database identifier for the action. For example:

<button type="action" name="123">Trigger</button>Will trigger action id 123 when clicked.

Is it possible to accomplish the same thing using the XML ID of the action rather than the database ID?

I'm asking because I have created a module full of data files that include view and window actions. The views include a reference to the ID of the window action since they contain buttons to trigger them. However, I don't know the ID's of the window actions until the module is imported, so I can't include them in the views on the initial import.

Is there any way around this?

0

Ray Carnes

--Ray Carnes--
20227
| 9 7 9
Keyport, United States
--Ray Carnes--

Senior ERP Analyst

OpenERP 6.1, 7.0; Odoo 8.0, 9.0, 10.0 and 11.0.

Completed Odoo Functional and Technical Training.

Functional Areas:

  • CRM/Sales

  • Inventory

  • Manufacturing

  • Accounting

  • Purchasing

Major Skills:

  • Business Process Reengineering

  • Efficiency Consulting

  • User Needs and GAP Analysis;

  • Functional and Technical Design;

  • Prototyping and Proof of Concepts;

  • Requirements Specifications;

  • Agile Implementation;

  • Data Migration;

  • Configuration & Customization (UI and code);

  • Integration - Odoo and non Odoo Applications and Services;

  • Training and Knowledge Transfer;

  • Go Live Support;

  • Helpdesk;

  • Version Upgrades and Migration.

  • Accounting Expert.

I have over 20 years of experience empowering and enabling users with enterprise information systems that make a real and measurable difference in their ability to proactively manage their businesses and organizations. 

I am a skilled Communicator and I only take the serious things seriously!

Ray Carnes
On 12/30/16, 10:41 PM

Yes.

Look at how Odoo does it in the Project module:

<record id="act_project_project_2_project_task_all" 
model="ir.actions.act_window">
...

<button
class="oe_stat_button"
type="action"
attrs="{'invisible':[('use_tasks','=', False)]}"
name="%(act_project_project_2_project_task_all)d"


If the window action is defined in the module where the button is defined, you can do it without a prefix of the module name (like the example above).  If your window action is in a different module (like the project module), prefix it like this:

name="%(project.act_project_project_2_project_task_all)d"

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.

Register

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)

Stats

Asked: 12/30/16, 9:27 PM
Seen: 3783 times
Last updated: 1/12/17, 11:56 PM