Odoo - How can I bind a window action to a first level menu in the sidebar? - odoo

I want to associate a window action to a menu placed in the left sidebar of Odoo interface. I have a menu named Academy in the top menu bar, and another menu named "Academy Content" in the left sidebar. Here is an image of the interface.
Link to image: Menus Odoo
The "Academy Content" menu doesn't have children. I want to associate a window action (named action_academy_teachers) to the "Academy Content" menu.
In the view (view.xml file), I'm defining two menus.
<menuitem sequence="0" id="menu_academy" name="Academy"/>
<menuitem id="menu_academy_content" parent="menu_academy" name="Academy Content" action="action_academy_teachers"/>
The problem is that I can't click on the "Academy Content" menu, it's only a static text, not a link.
But if I add a child menu (named "Academy Teachers") to the "Academy Content" menu, and I associate the window action "action_academy_teachers" to "Academy Teachers" menu, this window action is triggered when I click in this menu.
<menuitem sequence="0" id="menu_academy" name="Academy"/>
<menuitem id="menu_academy_content" parent="menu_academy"
name="Academy Content"/>
<menuitem id="menu_academy_content_teachers"
parent="menu_academy_content"
action="action_academy_teachers" name="Academy Teachers"/>
But I want to the "action_academy_teachers" action is triggered when I click on the "Academy Content" menu. I don't want to create another child menu to do this.
window action code:
<record id="action_academy_teachers" model="ir.actions.act_window">
<field name="name">Academy teachers</field>
<field name="res_model">academy.teachers</field>
</record>
Additional information:
Odoo: version 8
OS: Ubuntu 14.04 32 bit

Normaly it's not working by default, because of the architecture of menus and their structure.
So you need to modify how the menus are displayed, by overriding the "web.menu_secondary" template in "web" module, to add a link to your action.
To achieve that, just add this section to your XML file (or create a new module that depends on 'web' module) :
<template id="menu_secondary" inherit_id="web.menu_secondary">
<div class="oe_secondary_menu_section" position="replace">
<div class="oe_secondary_menu_section">
<span t-if="not menu['action']">
<t t-raw="menu['name']"/>
</span>
<span t-if="menu['action']">
<t t-call="web.menu_link"/>
</span>
</div>
</div>
</template>
Hope this can help!

Related

Outlook 2019: Button does not show up in Home Ribbon

I am writing an Outlook 2019 add-in for which I would like to place a button on the home tab. I am using ribbon xml and I am able to get this to successfully appear on the AddIns and View tab. However, I cannot get it to appear on the Home tab. This is my XML:
<tabs>
<tab idMso="TabHome">
<group id="ContentGroup" label="Custom Content">
<button id="textButton" label="Custom Button" screentip="Text" onAction="MethodCall"/>
</group>
</tab>
</tabs>
If I change "TabHome" to "TabView" then the button shows up at the end of the ribbon perfectly. Is there a special trick to making this work? Is the idMso of "TabHome" correct for outlook 2019?
Finally, what is the idMso for the "Message" tab when you're in a separate window with an email?
The correct idMSo is "TabMail".

Adding menu to Odoo 10 in custom module

I want to add a submenu to Settings->Technical menu in Odoo 10.
I have tried with the following code, apparently the menu item is loaded (you can see that it is one of the menus created by the custom module) but it is not displayed.
Any tip/suggestion on why?
<?xml version="1.0"?>
<odoo>
<menuitem id="sale_order_custom_document"
name="Sale Order Custom Documen"
parent="base.menu_custom"
/>
</odoo>
Thanks
You have to define the action in menuitem then only it is visible. menuitem without any action will became normal string for display purpose. So either add sub menu with action or directly assign any action to it.
<menuitem name="Sale Order Custom Document" action="<your_action_id>" id="sale_order_custom_document" parent="base.menu_custom" sequence="20"/>
Here's a description link for odoo action
you must also create the actions 's record named:
product.product_template_action_custom_docs for example
declare your menu just after
Try this:
<odoo>
<data>
<!-- your initial code in your <app>_view.xml -->
<record id="product.product_template_action_custom_docs" model="ir.actions.act_window">
<field name="name">Sale Order Custom Document</field>
<field name="res_model">product.template</field>
<field name="view_mode">tree,kanban,form</field>
<field name="view_type">form</field>
<field name="context">{"search_default_filter_to_sell":1}</field>
<field name="help" type="html">
<p> here you write the help form your form</p>
</field>
</record>
<!-- after the action, you can now paste your menu declaration
your specified "action", "id","name","sequence" and "parent"-->
<menuitem action="product.product_template_action_custom_docs"
id="sale_order_custom_document" parent="base.menu_custom" sequence="20" name="Sale Order Custom Document" />
</data>
<odoo>

Transparent context menu item during Thunderbird addon development

Currently i am developing a context menu addon for Thunderbird 3*. I am trying to add my own Submenu items as part of existing Thunderbird Context menu for mail content.
With the following XUL:
<?xml version="1.0"?>
<overlay id="sample"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<script type="application/javascript" src="chrome://elane/content/expoverlay.js"/>
<popup id="mailContext">
<menu id="elMenu" label="submenu 1">
<popup id="elMenu-popup">
<menuitem id="openBing"
label="Sub Menu Item 1"
oncommand="openURL('https://bing.com')"/>
<menuitem id="openGoogle"
label="Sub Menu Item 2"
oncommand="openURL('https://google.com')"/>
</popup>
</menu>
</popup>
</overlay>
The newly added Context menu item and submenu items are having transparent background:
Can anyone help me with the reason behind this and possible fix?
Change <popup id="elMenu-popup"> and corresponding </popup> to <menupopup id="elMenu-popup"> and </menupopup>

Joomla 3 Article Modal form field in custom module

I want to have an article picker in my custom module. A button and a form field like this one in add new article.
Is ist possible?
I tried this in my module xml:
<field name="article_id" type="modal_article" default="" label="Select an article" description="" />
But I only get a form input, not a button to choose an article.
You need to manually add the path to the modal article element.
In the < fieldset > element just above the modal_article field type, add the following attribute:
addfieldpath="/administrator/components/com_content/models/fields"
So your final xml would look something like this:
<fieldset name="basic" addfieldpath="/administrator/components/com_content/models/fields">
<field name="article_id" type="modal_article" default="" label="Select an article" description="" />

XUL: How do you create a nested menupopup inside a statusbarpanel (with statusbarpanel-menu-iconic)

In XUL you can use create a status bar panel icon, similar to the ones used by Firebug and Greasemonkey, with the <statusbarpanel> tag. If you set the right class, you can throw a <menupop> inside, and then have a pop-up menu when the user clicks on the icon, like so ...
<statusbarpanel class="statusbarpanel-menu-iconic"
src="chrome://YourExtension/content/icon.png">
<menupopup>
<menuitem label="whatever" oncommand="doSomething();">
<menuitem label="whatever else" oncommand="doSomethingElse();">
</menupopup>
</statusbarpanel>
Now, with other pop-up menus, you can nest a series of menus using the menu tag:
<statusbarpanel class="statusbarpanel-menu-iconic"
src="chrome://YourExtension/content/icon.png">
<menu value="Old">
<menupopup>
<menuitem label="whatever" oncommand="doSomething();">
<menuitem label="whatever else" oncommand="doSomethingElse();">
</menupopup>
</menu>
<menu value="New>
<menupopup>
<menuitem label="yet another" oncommand="doYetAnotherSomething();">
</menupopup>
</menu>
</statusbarpanel>
but the above code doesn't actually work, because <statusbarpanel> won't allow a <menu> child (well, it will allow it, but not create the desired effect).
So, what I was wondering was ... is there any way I can make a status bar panel icon-triggered menu with multiple layers of menu items?
* EDIT *
Since I can't post this in the comment to the answer (and get syntax coloring and such), here's what finally worked for me (thanks Sathish!):
<statusbarpanel class="statusbarpanel-menu-iconic"
src="chrome://YourExtension/content/icon.png" popup="stausBarPanelMenu">
</statusbarpanel>
<popup id="statusBarPanelMenu" position="start_before">
<menu value="Old">
<menupopup>
<menuitem label="whatever" oncommand="doSomething();">
<menuitem label="whatever else" oncommand="doSomethingElse();">
</menupopup>
</menu>
<menu value="New>
<menupopup>
<menuitem label="yet another" oncommand="doYetAnotherSomething();">
</menupopup>
</menu>
</popop>
Oh, and as a side note to any XUL devs who might read this: you should really eliminate the "menupopup inside a statusbarpanel" style of pop-up. The style that answered this question is just as easy to learn/use, significantly more powerful, and it relies on the same popup mechanisms that can be used with the other XUL elements. This whole "menupopup inside a statusbarpanel" this is just a confusing, un-needed, anomaly.
Try this:
create a popup element like this:
<popup ... >
<menu ... >
<menupopup ... >
<menuitem ... >
</menupopup ... >
</menu>
</popup>
assign the id of popup element to the oncontextmenu attribute or show it dynamically using onclick event of the statusbarpanel element.