Skip to Content
Odoo Menu
  • Sign in
  • Try it free
  • Apps
    Finance
    • Accounting
    • Invoicing
    • Expenses
    • Spreadsheet (BI)
    • Documents
    • Sign
    Sales
    • CRM
    • Sales
    • POS Shop
    • POS Restaurant
    • Subscriptions
    • Rental
    Websites
    • Website Builder
    • eCommerce
    • Blog
    • Forum
    • Live Chat
    • eLearning
    Supply Chain
    • Inventory
    • Manufacturing
    • PLM
    • Purchase
    • Maintenance
    • Quality
    Human Resources
    • Employees
    • Recruitment
    • Time Off
    • Appraisals
    • Referrals
    • Fleet
    Marketing
    • Social Marketing
    • Email Marketing
    • SMS Marketing
    • Events
    • Marketing Automation
    • Surveys
    Services
    • Project
    • Timesheets
    • Field Service
    • Helpdesk
    • Planning
    • Appointments
    Productivity
    • Discuss
    • Approvals
    • IoT
    • VoIP
    • Knowledge
    • WhatsApp
    Third party apps Odoo Studio Odoo Cloud Platform
  • Industries
    Retail
    • Book Store
    • Clothing Store
    • Furniture Store
    • Grocery Store
    • Hardware Store
    • Toy Store
    Food & Hospitality
    • Bar and Pub
    • Restaurant
    • Fast Food
    • Guest House
    • Beverage Distributor
    • Hotel
    Real Estate
    • Real Estate Agency
    • Architecture Firm
    • Construction
    • Estate Management
    • Gardening
    • Property Owner Association
    Consulting
    • Accounting Firm
    • Odoo Partner
    • Marketing Agency
    • Law firm
    • Talent Acquisition
    • Audit & Certification
    Manufacturing
    • Textile
    • Metal
    • Furnitures
    • Food
    • Brewery
    • Corporate Gifts
    Health & Fitness
    • Sports Club
    • Eyewear Store
    • Fitness Center
    • Wellness Practitioners
    • Pharmacy
    • Hair Salon
    Trades
    • Handyman
    • IT Hardware & Support
    • Solar Energy Systems
    • Shoe Maker
    • Cleaning Services
    • HVAC Services
    Others
    • Nonprofit Organization
    • Environmental Agency
    • Billboard Rental
    • Photography
    • Bike Leasing
    • Software Reseller
    Browse all Industries
  • Community
    Learn
    • Tutorials
    • Documentation
    • Certifications
    • Training
    • Blog
    • Podcast
    Empower Education
    • Education Program
    • Scale Up! Business Game
    • Visit Odoo
    Get the Software
    • Download
    • Compare Editions
    • Releases
    Collaborate
    • Github
    • Forum
    • Events
    • Translations
    • Become a Partner
    • Services for Partners
    • Register your Accounting Firm
    Get Services
    • Find a Partner
    • Find an Accountant
    • Meet an advisor
    • Implementation Services
    • Customer References
    • Support
    • Upgrades
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Get a demo
  • Pricing
  • Help

Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:

  • CRM
  • e-Commerce
  • Accounting
  • Inventory
  • PoS
  • Project
  • MRP
All apps
You need to be registered to interact with the community.
All Posts People Badges
Tags (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
Tags (View all)
odoo accounting v14 pos v15
About this forum
Help

how to add a button/field on the header of "tree" view?

Subscribe

Get notified when there's activity on this post

This question has been flagged
treeviewtree_view
9 Replies
28164 Views
Avatar
vx2008

I want to add a button and a field on the header of "tree" view at "create" and "import" button; 

how shall I do / set for this? or shall I to do this?

0
Avatar
Discard
peter

hi, did you manage to fix this ? I am using Odoo 11 and having the same problem.

OdooBot

i am sorry. i dont resolve this problem until now.

------------------ 原始邮件 ------------------
发件人: "peter"<hoth.peter@gmail.com>
发送时间: 2018年5月5日(星期六) 凌晨0:16
收件人: "vx2008"<caofa@foxmail.com>;
主题: Re: how to add a button/field on the header of "tree" view?

hi, did you manage to fix this ? I am using Odoo 11 and having the same problem.

--
peter


Sent by Odoo S.A. using Odoo.

Avatar
Odoo Developer
Best Answer


Create an xml file for qweb and also add in __openerp__.py

Example:

 'qweb':  ['static/src/xml/qweb.xml'],



In qweb.xml


<?xml version="1.0" encoding="UTF-8"?> 

<templates id="template" xml:space="preserve">

 <T t-extend = "ListView.buttons">


     <T t-jquery = "button.oe_list_add" t-operation = "after">
        <T t if = "widget.model == 'YOUR.MODEL'">
             <Button class = "oe_button" type = "button"> YOU BUTTON </ button>
         </ T>
     </ T>
</ T>
0
Avatar
Discard
vx2008
Author

there something eroro:

ERROR MeiTek openerp.http: Exception during JSON request handling.

ParseError: not well-formed (invalid token): line 10, column 67

<T t if = "widget.model == 'YOUR.MODEL'"> modified into <T t-if = "widget.model == 'Detection'">, <Button class = "oe_button" type = "button"> YOU BUTTON </ button> modified into <Button class = "oe_button" type = "button"> register</ button>

When I delete the "qweb" file, all is ok;

Maybe shall I add a common "field" instead of "button"?

vx2008
Author

I have modified a little about your code as below:

<?xml version="1.0" encoding="UTF-8"?>

<templates id="template" xml:space="preserve">

<T t-extend = "ListView.buttons">

<T t-jquery = "button.oe_list_add" t-operation = "after">

<T t-if = "widget.model == 'Detection'">

<button class = "oe_button" type = "button" string="Test"> register</button>

</T>

</T>

</T>

</templates>

in .py file:

@api.multi

def register(self):

print 'just a test!'

return True

my this module name: "Detection"; and I also created an qweb file as your request in "../addons/Detection/static/src/xml/qweb.xml";

when I modified the file and restart Odoo and update the "Detection" module; there is no error, but when I open the "tree", nothing changed.

Odoo Developer

You add your model name here .(Not module name)

Example :

<T t if = "widget.model == 'sale.order'">

The button will be appear in the tree view of sale.order

vx2008
Author

Thank you for you constant support; I have a try for that, but I still can;t see the button in tree view; now I will show all files here:

__init__.py : from . import meeting_model

__openerp__.py:

'name': 'Meeting Application',

'description': 'Publish a meeting',

'author': 'Odoo',

'application': True,

'qweb': ['qweb.xml'],

'data': ['meeting_view.xml']

}

meeting_model.py:

# -*- coding: utf-8 -*-

from openerp import models, fields,api

class MeetingTask(models.Model):

_name = 'meeting.task'

_description = 'Meeting task'

Theme = fields.Char('theme')

@api.multi

def register(self):

self.Theme='Just a test!'

qweb.xml:

<?xml version="1.0" encoding="utf-8"?>

<templates id="template" xml:space="preserve">

<T t-extend = "ListView.buttons">

<T t-jquery = "button.oe_list_add" t-operation = "after">

<T t-if = "widget.model == 'meeting.task'">

<button class = "oe_button" type = "button" >register</button>

</T>

</T>

</T>

</templates>

meeting_view.xml:

<?xml version="1.0"?>

<openerp>

<data>

<!-- Action to open To-Do Task list -->

<act_window id="action_meeting_task"

name="Meeting Tasks"

res_model="meeting.task"

view_mode="tree,form" />

<!-- Menu Item to open To-Do Task list -->

<menuitem id="menu_meeting_task"

name="Meeting"

sequence="20"

action="action_meeting_task" />

<!-- To-Do Task Form view -->

<record id="view_form_meeting_task" model="ir.ui.view">

<field name="name">Meeting Task Form</field>

<field name="model">meeting.task</field>

<field name="arch" type="xml">

<form>

<button name="register" type="object" string="Participate" />

<group name="group_top">

<field name="Theme"/>

</group>

</form>

</field>

</record>

<!-- To-Do Task List view -->

<record id="view_tree_meeting_task" model="ir.ui.view">

<field name="name">Meeting Task Tree</field>

<field name="model">meeting.task</field>

<field name="arch" type="xml">

<tree>

<field name="Theme"/>

</tree>

</field>

</record>

</data>

</openerp>

in addition, could you give me an example which add button/fields at create/import buttons on "tree" view? my email: 116599778@qq.com; thank you again!

Odoo Developer

I created the following module in odoo v9 and it works.

==================================================

◰ button_tree

-|___◰static

-|-----|___◰description

-|-----|___◰src

-|---------|___◰xml

-|--------------|___☐qweb.xml

-|___☐__init__.py

-|___☐__openerp__.py

==================================================

1) __init__.py : <empty>

2) __openerp__.py:

{

'name': 'Button at top of Tree',

'version': '1.0',

'author': 'Shameem',

'category': '',

'description': """ """,

'depends': ['sale'],

'data': [],

'qweb': ['static/src/xml/qweb.xml'],

'demo': [],

'installable': True,

'auto_install': False,

}

3) qweb.xml

<?xml version="1.0" encoding="UTF-8"?>

<templates id="template" xml:space="preserve">

<t t-extend="ListView.buttons">

<t t-jquery="button.o_list_button_add" t-operation="after">

<t t-if="widget.model=='sale.order'">

<button class="oe_button oe_highlight"

type="button">Custom Button</button>

</t>

</t>

</t>

</templates>

Avatar
Fotic
Best Answer

Probably im late but i will post it if someone need it in the future.

on Odoo 12 is modelName NOT model 

<t t-if="widget.modelName == 'stock.quant'">
 <button id="custom_print_btn" class="btn btn-primary o_list_button_custom_print" type="button" >Print</button> 
</t>
0
Avatar
Discard
Matt Pedrosa

where on the tree view code did you put this sir?

Enjoying the discussion? Don't just read, join in!

Create an account today to enjoy exclusive features and engage with our awesome community!

Sign up
Related Posts Replies Views Activity
How to show a new column in tree view for Sale Module
treeview tree_view v17
Avatar
Avatar
1
Jul 24
2101
How to create a new tree view for the model account.move
treeview account.move tree_view
Avatar
Avatar
1
Jul 22
3935
Error while printing a tree: Can't render view base.view_partner_form for model: res.partner
treeview tree tree_view
Avatar
1
Apr 16
4685
select check box for tree view inside a form
treeview xml tree_view
Avatar
0
Aug 15
8950
Show a field from many2many relationship in a tree view Solved
treeview tree many2many tree_view
Avatar
Avatar
Avatar
Avatar
4
Jun 25
12396
Community
  • Tutorials
  • Documentation
  • Forum
Open Source
  • Download
  • Github
  • Runbot
  • Translations
Services
  • Odoo.sh Hosting
  • Support
  • Upgrade
  • Custom Developments
  • Education
  • Find an Accountant
  • Find a Partner
  • Become a Partner
About us
  • Our company
  • Brand Assets
  • Contact us
  • Jobs
  • Events
  • Podcast
  • Blog
  • Customers
  • Legal • Privacy
  • Security
الْعَرَبيّة Català 简体中文 繁體中文 (台灣) Čeština Dansk Nederlands English Suomi Français Deutsch हिंदी Bahasa Indonesia Italiano 日本語 한국어 (KR) Lietuvių kalba Język polski Português (BR) română русский язык Slovenský jazyk slovenščina Español (América Latina) Español ภาษาไทย Türkçe українська Tiếng Việt

Odoo is a suite of open source business apps that cover all your company needs: CRM, eCommerce, accounting, inventory, point of sale, project management, etc.

Odoo's unique value proposition is to be at the same time very easy to use and fully integrated.

Website made with

Odoo Experience on YouTube

1. Use the live chat to ask your questions.
2. The operator answers within a few minutes.

Live support on Youtube
Watch now