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
เกี่ยวกับฟอรั่มนี้
ช่วยเหลือ

How to edit a record directly in a treeview (which is returned by a python function) ?

ติดตาม

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

คำถามนี้ถูกตั้งค่าสถานะ
12 ตอบกลับ
16102 มุมมอง
อวตาร
MIADI

Hello,

In a module that I've created, when I click on a menuitem (Weight/number ratio), I execute a python function that returns a treeview. I want to be able to edit a record directly in this treeview.

Python function :

@api.multi

@api.model

def chargement_ratio(self):

        productRatio = self.env['miadi.poidsconditionnement']

        conditionnements = self._cr.execute("SELECT id FROM miadi_packaging")

        query_cond = self.env.cr.dictfetchall()

        produits = self._cr.execute("SELECT id FROM product_product")

        query_prod = self.env.cr.dictfetchall()

        for conditionnements in query_cond:

                nom_conditionnement = conditionnements['id']

                for produits in query_prod:

                        product = produits['id']

                        if_exist = self._cr.execute("SELECT * FROM miadi_poidsConditionnement WHERE conditionnement_id=%s AND produit_id=%s", (nom_conditionnement, product))

                        exist = self.env.cr.dictfetchall()

                        if not exist:

                                Ratio = productRatio.create({'conditionnement_id': nom_conditionnement, 'produit_id': product})

        return {'name': _('Weight/number Ratio'), 'view_type': 'tree', 'view_mode': 'tree', 'view_id': self.env.ref('miadi_packaging.miadi_poidsConditionnement_tree').id, 'res_model': 'miadi.poidsconditionnement', 'type': 'ir.actions.act_window', 'target': 'current',}


XML code :

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

        <field name="name">miadi.poidsconditionnement.tree</field>

        <field name="model">miadi.poidsconditionnement</field>

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

                <tree string="Weight/number ratio" editable="bottom">

                        <field name="produit_id" ref="product.product.attribute_value_ids" />

                        <field name="conditionnement_id" ref="miadi.packaging.conditionnement_id" />

                        <field name="nb_articles" />

                        <field name="poids" />

                </tree>

        </field>

</record>

<record model="ir.actions.act_window" id="action_miadi_poidsConditionnement">

        <field name="name">Weight/number ratio</field>

        <field name="type">ir.actions.act_window</field>

        <field name="res_model">miadi.poidsconditionnement</field>

        <field name="view_type">form</field>

        <field name="view_mode">tree,form</field>

        <field name="view_id" ref="miadi_poidsConditionnement_tree"/>

        <field name="help" type="html">

                <p class="oe_view_nocontent_create">Click here to create a weight/number ratio.</p>

        </field>

</record>

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

        <field name="name">Chargement Ratio</field>

        <field name="type">ir.actions.server</field>

        <field name="model_id" ref="model_miadi_poidsconditionnement"/>

        <field name="code">action = env['miadi.poidsconditionnement'].chargement_ratio()</field>

</record>

<menuitem name="Weight/number ratio" id="menu_miadi_poidsConditionnement" parent="menu_miadi_packaging" sequence="15" action="action_chargement_ratio" />


Pictures for help :

The treeview returned by the function : https://www.hostingpics.net/viewer.php?id=651454Capturetreeview3.png
What I want to be able to do : https://www.hostingpics.net/viewer.php?id=575162Capturesaisie.png


PS : I'm on Odoo 10


Thanks for answer

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

Dear Miadi,

Try to change view_type: form  instead of tree

return {'name': _('Weight/number Ratio'), 'view_type': 'form', 'view_mode': 'tree', 'view_id': self.env.ref('miadi_packaging.miadi_poidsConditionnement_tree').id, 'res_model': 'miadi.poidsconditionnement', 'type': 'ir.actions.act_window', 'target': 'current',}




I hope I helped you...
2
อวตาร
ละทิ้ง
MIADI
ผู้เขียน

Thank you very much it works !

อวตาร
Niyas Raphy (Walnut Software Solutions)
คำตอบที่ดีที่สุด

Hi Miadi,

You can make a tree view editable by adding "editable="top" " in the tree view.

I will attach a sample code where you can edit the tree view.

<tree string="Student" editable="top">

Thank You


<record id="view_admission_student_tree" model="ir.ui.view">
<field name="name">admission.student.tree</field>
<field name="model">course.admission</field>
<field name="priority" eval="8" />
<field name="arch" type="xml">
<tree string="Student" editable="top">
<field name="name" />
<field name="middle_name" />
<field name="last_name" />
</tree>
</field>
</record>
4
อวตาร
ละทิ้ง
MIADI
ผู้เขียน

Hi Niyas,

If you look my XML code, you can see I've put : <tree editable="bottom"> but it doesn't work.

First, if you look my pictures (on links), you can see I've not a normal treeview, I can't create or select records

Niyas Raphy (Walnut Software Solutions)

Hi miadi,

You are getting such a tree view because you are returning a tree view from the python as view mode, it would be better if you can add a form view and return view mode as the form view. Then you will get the normal tree view

MIADI
ผู้เขียน

Hi Niyas, can you give an example please ?

Thanks

Niyas Raphy (Walnut Software Solutions)

Hi, i will add the code in the python, you also have to add a from view in the xml.

list_view_id = imd.xmlid_to_res_id('account.invoice_tree')

form_view_id = imd.xmlid_to_res_id('account.invoice_form')

result = {

'name': action.name,

'help': action.help,

'type': action.type,

'views': [[list_view_id, 'tree'], [form_view_id, 'form'], [False, 'graph'], [False, 'kanban'], [False, 'calendar'], [False, 'pivot']],

'target': action.target,

'context': action.context,

'res_model': action.res_model,

}

MIADI
ผู้เขียน

and if I already a form view in my xml ?

Here :

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

<field name="name">miadi.poidsconditionnement.form</field>

<field name="model">miadi.poidsconditionnement</field>

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

<form string="Weight/number ratio">

<group col="4">

<field name="produit_id" />

<field name="conditionnement_id" />

<field name="nb_articles" />

<field name="poids" />

</group>

</form>

</field>

</record>

Niyas Raphy (Walnut Software Solutions)

in the python, make view_type as from

MIADI
ผู้เขียน

Thank you very much it works !

Mitesh Dhaduk

How to make only one field editable in the tree view. And on other field click action open tree view.

อวตาร
yasir iqbal
คำตอบที่ดีที่สุด

how to create the record in tree please as soon as possible i am new 

0
อวตาร
ละทิ้ง
สนุกกับการพูดคุยนี้ใช่ไหม? เข้าร่วมเลย!

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

ลงชื่อ
คอมมูนิตี้
  • บทเรียน
  • เอกสารกำกับโปรแกรม
  • ฟอรั่ม
โอเพนซอร์ส
  • ดาวน์โหลด
  • 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