Skip to Content
Odoo เมนู
  • ลงชื่อเข้าใช้
  • ทดลองใช้ฟรี
  • แอป
    การเงิน
    • ระบบบัญชี
    • ระบบการออกใบแจ้งหนี้
    • ระบบบัญชีรายจ่าย
    • ระบบการจัดการข้อมูลผ่านสเปรดชีต (BI)
    • เอกสาร
    • ระบบลงลายเซ็น
    การขาย
    • ลูกค้าสัมพันธ์
    • การขาย
    • POS ร้านค้า
    • POS ร้านอาหาร
    • ระบบสมัครสมาชิก
    • การเช่า
    การจัดการเว็บไซต์
    • เครื่องมือสร้างเว็บไซต์
    • ระบบการขายออนไลน์
    • บล็อก
    • ฟอรั่ม
    • ไลฟ์แชท
    • ระบบการอบรมออนไลน์
    ซัพพลายเชน
    • คลังสินค้า
    • ระบบการผลิต
    • PLM
    • ระบบการจัดซื้อ
    • การซ่อมบำรุง
    • ระบบจัดการคุณภาพ
    ทรัพยากรบุคคล
    • ข้อมูลพนักงาน
    • ระบบสรรหาบุคลากร
    • ระบบการลา
    • การประเมิน
    • ระบบการแนะนำพนักงาน
    • ระบบจัดการยานพาหนะ
    การตลาด
    • โซเชียลมาร์เก็ตติ้ง
    • การตลาดผ่านอีเมล
    • ระบบการตลาดผ่าน SMS
    • ระบบการจัดงานอีเวนต์
    • การตลาดแบบอัตโนมัติ
    • ระบบแบบสำรวจ
    การบริการ
    • โปรเจกต์
    • ระบบบันทึกเวลา
    • ระบบการจัดการบริการภาคสนาม
    • ระบบดูแลช่วยเหลือ
    • การวางแผน
    • การนัดหมาย
    ประสิทธิผล
    • ระบบแสดงความคิดเห็น
    • ระบบการอนุมัติ
    • ไอโอที
    • VoIP
    • คลังข้อมูล
    • WhatsApp
    แอปพลิเคชันของบุคคลที่สาม Odoo สตูดิโอ แพลตฟอร์มคลาวด์ของ Odoo
  • อุตสาหกรรม
    การค้าปลีก
    • ร้านขายหนังสือ
    • ร้านขายเสื้อผ้า
    • ร้านขายเฟอร์นิเจอร์
    • ร้านขายของชำ
    • ร้านขายฮาร์ดแวร์
    • ร้านขายของเล่น
    Food & Hospitality
    • บาร์และผับ
    • ร้านอาหาร
    • อาหารฟาสต์ฟู้ด
    • Guest House
    • ตัวแทนจำหน่ายเครื่องดื่ม
    • Hotel
    อสังหาริมทรัพย์
    • Real Estate Agency
    • บริษัทสถาปัตยกรรม
    • บริษัทรับเหมา
    • การจัดการอสังหาริมทรัพย์
    • การจัดสวน
    • สมาคมเจ้าของอสังหาริมทรัพย์
    ปรึกษา
    • สำนักงานบัญชี
    • Odoo พาร์ทเนอร์
    • เอเจนซี่การตลาด
    • สำนักงานกฎหมาย
    • บริการสรรหาบุคลากร
    • การตรวจสอบและการรับรอง
    ระบบการผลิต
    • Textile
    • เหล็ก
    • เฟอร์นิเจอร์
    • อาหาร
    • Brewery
    • ของขวัญขององค์กร
    สุขภาพ & ฟิตเนส
    • ชมรมกีฬา
    • ร้านขายแว่นตา
    • ฟิตเนส
    • ผู้ประกอบวิชาชีพด้านสุขภาพ
    • ร้านขายยา
    • ร้านทำผม
    Trades
    • ช่างซ่อม
    • ฮาร์ดแวร์และการสนับสนุนด้านไอที
    • ระบบพลังงานแสงอาทิตย์
    • ช่างทำรองเท้า
    • บริการทำความสะอาด
    • HVAC Services
    อื่น ๆ
    • Nonprofit Organization
    • สำนักงานสิ่งแวดล้อม
    • ร้านเช่าป้ายโฆษณา
    • การถ่ายภาพ
    • ร้านเช่าจักรยาน
    • ตัวแทนจำหน่ายซอฟต์แวร์
    Browse all Industries
  • คอมมูนิตี้
    ศึกษา
    • บทเรียน
    • เอกสารกำกับโปรแกรม
    • การรับรอง
    • การฝึกอบรม
    • บล็อก
    • พอดแคสต์
    เพิ่มศักยภาพให้กับการศึกษา
    • โปรแกรมการศึกษา
    • Scale Up! Business Game
    • เยี่ยมชม Odoo
    รับซอฟต์แวร์
    • ดาวน์โหลด
    • เปรียบเทียบรุ่น
    • เผยแพร่
    ทำงานร่วมกัน
    • Github
    • ฟอรั่ม
    • ระบบการจัดงานอีเวนต์
    • การแปล
    • ร่วมเป็นพาร์ทเนอร์
    • Services for Partners
    • ลงทะเบียนเพื่อสร้างบัญชีบริษัทของคุณ
    รับบริการ
    • ค้นหาพาร์ทเนอร์
    • ค้นหานักบัญชี
    • พบกับที่ปรึกษา
    • บริการติดตั้งระบบเพื่อใช้งาน
    • ข้อมูลอ้างอิงลูกค้า
    • การสนับสนุน
    • อัปเกรด
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    รับการสาธิต
  • ราคา
  • ช่วยเหลือ

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

  • ลูกค้าสัมพันธ์
  • e-Commerce
  • ระบบบัญชี
  • สินค้าคงคลัง
  • PoS
  • โปรเจกต์
  • MRP
All apps
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
All Posts คน เหรียญรางวัล
แท็ก (View all)
odoo accounting v14 pos v15
เกี่ยวกับฟอรั่มนี้
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
All Posts คน เหรียญรางวัล
แท็ก (View all)
odoo accounting v14 pos v15
เกี่ยวกับฟอรั่มนี้
ช่วยเหลือ

Assign action menu item to specific tree view

ติดตาม

รับการแจ้งเตือนเมื่อมีกิจกรรมในโพสต์นี้

คำถามนี้ถูกตั้งค่าสถานะ
actionmenuodoo9odoo10
7 ตอบกลับ
22913 มุมมอง
อวตาร
ged

Is it possible to assign custom menu action to specific treeview view? Im trying to archieve that i want to have a few different tree views for stock.moves model, and i want a custom action to each of the tree view, but i dont want show all actions in all custom views. So it should look like that:

one model - stock.moves

1.custom tree view + custom action 1

2.custom tree view + custom action 2

3.custom tree view + custom action 3

With the current Odoo design all i can get is:

1.custom tree view + custom action 1 + custom action 2 + custom action 3

2.custom tree view + custom action 1 + custom action 2 + custom action 3

3.custom tree view + custom action 1 + custom action 2 + custom action 3

I thought about a custom button, but its not possible to create one in a tree view, like in form view...Or maybe there are othe work arounds for this situation? thank you

1
อวตาร
ละทิ้ง
อวตาร
ged
ผู้เขียน คำตอบที่ดีที่สุด

Hello Vishal, if you will add button like this, button will appear on each line, but its not what im looking for. I need a button in a action menu, after you select records, and i need different action on a different treeview but same model. I have tried your suggestion on view_move_tree in stock module, and it gives me button in line.

1
อวตาร
ละทิ้ง
Vishal Kapuriya

Okay, you can add button in more option in tree view. from where you can call your python method.

Ex.

<record id="open_invoice" model="ir.actions.server">

<field name="name">Open Invoice</field>

<field name="model_id" ref="account.model_account_invoice"/>

<field name="state">code</field>

<field name="code">action = self.open_invoice_from_list(cr, uid, context.get('active_ids', []), context=context)</field>

</record>

<record id="action_open_invoice" model="ir.values">

<field eval="'client_action_multi'" name="key2"/>

<field eval="'account.invoice'" name="model"/>

<field name="name">Open Product</field>

<field eval="'ir.actions.server,%d'%open_invoice" name="value"/>

</record>

here open_invoice_from_list is python method for account.invoice.

i hope this is helpful.

ged
ผู้เขียน

Yes i know that is possible to add a button in an Action or More menu. But lets say you 3 custom tree views in a stock.move model, if you will add a menu in Action or More, it will appear in all custom views of stock.move model. What i want, is to add a menu item in More menu in one custom tree view menu, not in all.

อวตาร
Jim At Your Service
คำตอบที่ดีที่สุด

I wrote a module 'web_menu_action_if' to accomplish this task in Odoo 9.0.

__openerp__.py

#---------------------------------------------------------------------------------------------
# addons/web_menu_action_if/__openerp__.py
#
# 13.0.7.5.16-t1 jimays
# code--129a-0131-3bbbb54b-8e81-ad5c3982c542--13.0.7.5.16-t1--2.55.04--99.91--RFGkfM=y9Z9IcFW=KgtmZ7
#---------------------------------------------------------------------------------------------
{
'name': 'Web Menu Action If',
'category': 'Hidden',
'author': '©INTER-DIMENSIONAL-SPACE-PORT',
'website': 'http://inter-dimensional-space-port.net',
'description': """
So you can have items on the Action menu for a model only for selected views.

Makes any action with xml_id starting with 'action_if_xyz_then_' or 'action_if_not_xyz_then_'
invisible unless the context has or does not have 'action_if_xyz_then': 1.

For example, define an action with id="module.action_if_my_view_then_do_something"
and then on your ir.actions.act_window which loads your view, include context="{'action_if_my_view': 1}".

If you want an action to not appear on your view, use id="module.action_if_not_my_view_then_something_else".

Using this mechanism, I was able to make a Payment Transfer view that has certain actions
and have certain other actions only show up on the default Sales Payments and Purchase Payments views.

<record id="action_account_payment_transfers" model="ir.actions.act_window">
<field name="name">Payment Transfers</field>
<field name="res_model">account.payment</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form,graph</field>
<field name="context">{
'default_payment_type': 'transfer',
'actions_if_payment_transfer': 1,
}</field>
<field name="domain">[('payment_type', '=', 'transfer')]</field>
<field name="view_id" ref="view_account_payment_transfer_tree"/>
</record>

<record id="actions_if_payment_transfer_then_unreconcile_and_cancel" model="ir.actions.server">
...
</record>

<record id="actions_if_not_payment_transfer_then_create_journal_entry_in_lieu_of_invoice" model="ir.actions.server">
...
</record>
""",
'version': '1.0',
'depends': ['web'],
'data': [
'views/assets.xml',
],
}

views/assets.xml

<openerp>
<data>
<template id="web_menu_action_if_assets_js" name="Web Menu Action If JS Assets" inherit_id="web.assets_backend">
<xpath expr="script[last()]" position="after">
<script type="text/javascript" src="/web_menu_action_if/static/src/js/web_menu_action_if.js"></script>
</xpath>
</template>
</data>
</openerp>

static/src/js/web_menu_action_if.js

//---------------------------------------------------------------------------------------------
// addons/web_menu_action_if/static/src/js/web_web_menu_action_if.js
//
// 13.0.7.5.16-t1 jimays
// code--129a-0131-5569d629-9db5-6bbf278af157--13.0.7.5.16-t1--2.59.35--99.03--HcOEijfrP025AMkdHahOoh
//---------------------------------------------------------------------------------------------

// gratitude addons/web/static/src/js/widgets/sidebar.js
// gratitude https://www.odoo.com/forum/help-1/question/how-to-get-context-value-from-js-to-python-function-in-odoo-91728
// gratitude https://stackoverflow.com/questions/9882284/looping-through-array-and-removing-items-without-breaking-for-loop
// gratitude https://www.w3schools.com/jsref/jsref_includes.asp
// gratitude https://stackoverflow.com/questions/47049062/non-greedy-regular-expression-for-javascript
// gratitude https://www.w3schools.com/jsref/jsref_substr.asp
// gratitude https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/exec

odoo.define('web.action_if', function (require) {
'use strict';

var Sidebar = require('web.Sidebar');

var re_actions_if = new RegExp('^[^.]+\.(actions_if_.*?)_then_.+$');

true || console.log('starting web_menu_action_if.js');

Sidebar.include({
add_toolbar: function(toolbar) {
var self = this;

var context = self.getParent().dataset.get_context().eval();
true || console.log('context: ' + JSON.stringify(context));

_.each(['print','action','relate'], function(type) {
var items = toolbar[type];
if (items) {

// Make any action with xml_id starting with 'action_if_xyz_then_' or 'action_if_not_xyz_then_'
// invisible unless the context has or does not have 'action_if_xyz_then': 1.
for (var i = items.length-1; i >= 0 ; i--) {
var matches = re_actions_if.exec(items[i].xml_id);
var actions_if = matches ? matches[1] : '';
var flip = (actions_if.indexOf('actions_if_not') == 0);
if (flip) {
actions_if = 'actions_if' + actions_if.substr(14);
}
var visible = (!actions_if
|| (!flip && context[actions_if]) || (flip && !context[actions_if]));

true || console.log(
'item xml_id: ' + items[i].xml_id
+ ', actions_if: ' + actions_if + ', flip: ' + flip
+ ', context[actions_if]: ' + context[actions_if] + ', visible: ' + visible);

if (!visible) {
true || console.log('action invisible: ' + items[i].xml_id);
items.splice(i, 1);
}
}

// Repeat code from core web module to install actions in the sidebar.

for (var i = 0; i < items.length; i++) {
items[i] = {
label: items[i]['name'],
action: items[i],
classname: 'oe_sidebar_' + type
};
}
self.add_items(type=='print' ? 'print' : 'other', items);
}
});
},
});

}); // end odoo.define('', function() {

Enjoy!

0
อวตาร
ละทิ้ง
อวตาร
Vishal Kapuriya
คำตอบที่ดีที่สุด

I thought about a custom button, but its not possible to create one in a tree view, like in form view...Or maybe there are othe work arounds for this situation?
>>> You can create button tree view and call python method then you can do anything you want.

Ex.

<tree>

     <button name="open_product" type="object" string="Open Product" icon="gtk-go-forward"/>

</tree>

0
อวตาร
ละทิ้ง
ged
ผู้เขียน

Hello Vishal, if you will add button like this, button will appear on each line, but its not what im looking for. I need a button in a action menu, after you select records, and i need different action on a different treeview but same model. I have tried your suggestion on view_move_tree in stock module, and it gives me button in line.

Vishal Kapuriya

Okay, you can add button in more option in tree view. from where you can call your python method.

Ex.

<record id="open_invoice" model="ir.actions.server">

<field name="name">Open Invoice</field>

<field name="model_id" ref="account.model_account_invoice"/>

<field name="state">code</field>

<field name="code">action = self.open_invoice_from_list(cr, uid, context.get('active_ids', []), context=context)</field>

</record>

<record id="action_open_invoice" model="ir.values">

<field eval="'client_action_multi'" name="key2"/>

<field eval="'account.invoice'" name="model"/>

<field name="name">Open Product</field>

<field eval="'ir.actions.server,%d'%open_invoice" name="value"/>

</record>

here open_invoice_from_list is python method for account.invoice.

i hope this is helpful.

สนุกกับการพูดคุยนี้ใช่ไหม? เข้าร่วมเลย!

สร้างบัญชีวันนี้เพื่อเพลิดเพลินไปกับฟีเจอร์พิเศษและมีส่วนร่วมกับคอมมูนิตี้ที่ยอดเยี่ยมของเรา!

ลงชื่อ
Related Posts ตอบกลับ มุมมอง กิจกรรม
odoo 10 action menu button
action menu odoo10
อวตาร
อวตาร
1
มิ.ย. 17
4818
Call view from 'More'/'Action' Menu แก้ไขแล้ว
action menu ir.values odoo10 More-Menu
อวตาร
อวตาร
4
ธ.ค. 18
8974
[odoo10] default search for sub-menu
menu odoo10
อวตาร
อวตาร
2
ก.ย. 18
3591
How to show informations hierarchically in views ?
odoo9 odoo10
อวตาร
0
ก.ค. 17
3460
So difficult to describe franchising situation in Odoo?
odoo9 odoo10
อวตาร
0
มี.ค. 17
3691
คอมมูนิตี้
  • บทเรียน
  • เอกสารกำกับโปรแกรม
  • ฟอรั่ม
โอเพนซอร์ส
  • ดาวน์โหลด
  • Github
  • Runbot
  • การแปล
บริการ
  • โฮสติ้ง odoo.sh เซิร์ฟเวอร์
  • การสนับสนุน
  • อัปเกรด
  • การพัฒนาที่กำหนดเอง
  • การศึกษา
  • ค้นหานักบัญชี
  • ค้นหาพาร์ทเนอร์
  • ร่วมเป็นพาร์ทเนอร์
เกี่ยวกับเรา
  • บริษัทของเรา
  • ทรัพย์สินในรูปของเครื่องหมายการค้า
  • ติดต่อเรา
  • งาน
  • ระบบการจัดงานอีเวนต์
  • พอดแคสต์
  • บล็อก
  • ลูกค้า
  • กฎหมาย • ความเป็นส่วนตัว
  • ความปลอดภัย
الْعَرَبيّة 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 เป็นชุดแอปธุรกิจแบบเปิดที่ครอบคลุมทุกความต้องการของบริษัทของคุณ อาธิ CRM eCommerce ระบบบัญชี ระบบสินค้าคงคลัง ระบบการขายหน้าร้าน โปรเจกต์ และ อีกมากมาย

ความเหนือกว่าอันเป็นเอกลักษณ์ของ Odoo คือการใช้งานที่ง่ายดายและผสานการทำงานอย่างสมบูรณ์แบบในเวลาเดียวกัน

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