Odoo window action button using XML ID - odoo

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?

Found my answer:
<button type="action" name="%(xml_id_of_action)d"></button>

Related

How can a popup window store additional field value in odoo?

According to scenario , i need, when user click button from main view (model name ='StudentRegistration') to open a new popup window. New opened window select drop down list option and save it into main model e.g 'StudentRegistration'.
how can i do this operation where popup window is opening.?
Try this:
Create an intermediate model. Add all your required fields to this model. Create a form view for this model. Call this view on a button click. While saving this form view, access your main model and add data from here to main model.
EDIT: To call a view from button use like this:
<button name="%( view ID )d" string="Documents" context="{'default_cases':active_id}" type="action" />

How to disable/remove the "Create", "Write" operations for users in a group, but only on some views

I have a special user group who is allowed to create new res.partner instances, but only if they go through a series of steps with custom views.
On the other hand, they have restricted view possibilities on res.partner.
Thus in CRUD terminology, these users have the Create right.
On the other hand, I don't want to provide them general create rights, but only if the follow their partner wizard view.
Still, they have the Read right as well on res.partner, thus I would like to present them with a link to the tree view without a Create button.
How can I set this up?
In your case you want to hide create button from tree view.
May be this will help you...
<tree create="false">
....
</tree>
create="flase", this will be hide your create button.
You can use this one in also your kanban view & form view.
Same way you can use edit="false" to hide your edit button, and also delete="false" for delete option.
<kanban create="false" edit="false">
....
</kanban>

MVC4 Dynamic Menu Generation

I want to generate menu from database for that I have implemented my logic and its responding well, the issue is that I am unable to render menu from my controller method. I want to ask if its possible to return HTML from action controller method and render it on my view by using Html.Action("MenuGenerator","Menu") but I am unable to achieve this. Moreover I donot want to create partial view for menu since my method returns menu as html string and I just want to flush it out to the view.
Html.Action is a basic helper method. All it does is return a MVCHtmlString. You will have to create your own helper extension that returns your custom HTML to build your menu.

Inherit form view from a predefined module

I want to create my own module which is an extension of sale.order. I want to have a form view which is like sale order view with few additional fields,
My problem is that when I inherit the sale order view and add say three extra fields these fields comes by default in the Original Sale Order form view too.
is this the default behaviour or am I doing something wrong ?
What should I do to achieve what I want.
If you inherit the view and add some fields using 'xpath' , than it will change the original view by installing your new module. This is the application of view inheritance. If you want to keep the original form view as it is after the installation of your module and want to define another which have some extra fields only for your customized module, you have to make a different form view without inheriting the original one. May be in future , there will be a facility of extending an existing form view, but right now you can't do that.
I think you need to check view_id in your code may be a view_id is common so you are updating a default view of sale order.
When you are inherit one view of sale order a functionality will be added in a form not whole view will be generated.
Still this is not solution send me your code i will review it.

hide button according to group

I have a defined groups and i want to display a button according a group.
<button name="assign_ticket" states= "pending_assignment,draft" groups="group_centricare_care_agents" string="Assign to me"/>
i want this button to be displayed to the group "roup_centricare_care_agents" but when adding groups tag it cause an exception.
P.S.: This button in tree view.
How can i do this??
Thanks in advance
I think the groups attribute has to have the module name included in the group name. For example, groups="base.group_extended" is used a lot. The module name should be from the module that originally created the group. It might also be that the groups attribute is not supported in tree views or on buttons, I don't know.
Can you post details of what your error says?
I have also faced a same problem, i am using openerp 7 on window and when i edit the following code
buton name="purchase_approve" states="confirmed" string="Approve Order" class="oe_highlight" groups="base.gm_approved"
in form view of purchase order for access the button only for gm_approved group then this button does not show for any user. also i try groups="base.group_gm_approved" but same issue