Skip to Content
Menu
This question has been flagged
1 Reply
6530 Views

I created an extension of the form view that adds a button to the toolbar similar to the HelloworldEvolution view from this video here: 

https://www.youtube.com/watch?v=SIoljYJhTqk

Github repo for the video:

https://github.com/Polymorphe57/hello_world_view_code

The extension just adds a button to the toolbar that doesn't do anything yet. Now I'd like to use this extension in an existing view, like the stock.picking form view from the Inventory app.

I tried inheriting the view and adding the js_class attribute to it using:

<xpath expr="//form" position="attributes">
    <attribute name="js_class">my_formview_extension</attribute>
</xpath>

But nothing gets added to the form. No error is thrown either. Anyone can help?

Thanks!

Avatar
Discard
Best Answer

Hi,,

Its clearly described in the repository that "This repository contains the code of the hello world view that was presented at the Odoo Experience 2018 during the talk entitled "Visualizing Data in Odoo: How to Create a New View" , you can clearly read at  https://github.com/Polymorphe57/hello_world_view_code/blob/master/README.md

It create new type of view!

But based on your syntax,, you try to use in "FORM" view,, it wouldn't be executed!

Avatar
Discard
Author

Then my wording must have been unclear, and I apologize for that. What I meant to say was that I used some of the references from that video to create an extension of the form view, similarly to the HelloWorldEvolution extension that the developper in the video created for the HelloWorld View. I did not create a helloworld view, I extended the Form View to add a couple buttons to it.

I think it can do by add button on form header in xml (for simple ways)

Ex:

<xpath expr="//form/header">

<button name="ex_btn_action" type="object" string="EXAMPLE BUTTON" />

</xpath>

and if you wanna to no action when clicked,, you just only need to define method in python that only just return False/None Value

Ex:

def ex_btn_action(self):

return None

But if you wanna advanced way to add button at the toolbar and wanna to apply to all form view ,, you must inherit odoo web js class "web.FormRenderer"

How to inheriting js class, you can read here as reference:

https://www.odoo.com/documentation/11.0/reference/javascript_cheatsheet.html#modifying-a-main-widget-from-the-interface

https://odoo-development.readthedocs.io/en/latest/dev/pos/gui.html

Regards

sorry miss for the example

<xpath expr="//form/header" position="inside">

<button name="ex_btn_action" type="object" string="EXAMPLE BUTTON" />

</xpath>

Author

Thank you, Yarsyah. I'll be sure to try all of these things and see which one fits my needs best :)

Related Posts Replies Views Activity
2
Jul 22
1494
3
Dec 19
2259
2
Jul 23
784
0
Dec 19
3617
1
Jul 19
3902