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

Odoo 10 | How to pass context from "ir.actions.act_window.view" to one2many field

ติดตาม

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

คำถามนี้ถูกตั้งค่าสถานะ
openerpodoo10.0
14929 มุมมอง
อวตาร
Wiem

Hi,

in account.invoice i have done:

class AccountInvoice(models.Model):

    _inherit = "account.invoice"

   invoice_type = fields.Selection([

            ('simple_invoice','Simple Invoice'),

            ('progress_invoice','Progress Invoice'),

        ], string = "Invoice Type", readonly=True, index=True, change_default=True,

        default=lambda self: self._context.get('invoice_type', 'simple_invoice'),

        track_visibility='always')

class AccountInvoiceLine(models.Model):    

    _inherit = "account.invoice.line"

    amount_net_ht = fields.Monetary(string='Amount Net of the month HT', store=True, readonly=True)

    previous_amount_ht = fields.Monetary(string='Previous Cumulative amount HT', store=True, readonly=True)


in xml i made new action and new menuitem for that action that displays account invoice form for progress_invoice type that i added : 

<record id="account.action_invoice_tree1" model="ir.actions.act_window">

            <field name="name">Simple Invoices</field>

            <field name="res_model">account.invoice</field>

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

            <field name="view_mode">tree,kanban,form,calendar,pivot,graph</field>

            <field eval="False" name="view_id"/>

            <field name="domain">[('type','in',['out_invoice', 'out_refund']), ('invoice_type','=','simple_invoice')]</field>

            <field name="context">{'type':'out_invoice', 'journal_type': 'sale'}</field>

            <field name="search_view_id" ref="account.view_account_invoice_filter"/>

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

              <p class="oe_view_nocontent_create">

                Click to create a simple invoice.

              </p>

            </field>

        </record>

        

        <record id="action_situation_invoice" model="ir.actions.act_window">  # new action added for Progress Invoice

            <field name="name">Progress Invoices</field>

            <field name="res_model">account.invoice</field>

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

            <field name="view_mode">tree,kanban,form,calendar,pivot,graph</field>

            <field eval="False" name="view_id"/>

            <field name="domain">[('type','in',['out_invoice', 'out_refund']), ('invoice_type','=','progress_invoice')]</field>

            <field name="context">{'invoice_type':'progress_invoice'}</field> 

            <field name="search_view_id" ref="account.view_account_invoice_filter"/>

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

              <p class="oe_view_nocontent_create"> 

                Click to create a progress invoice.

              </p>

            </field>

        </record>


        <record id="action_situation_invoice_view1" model="ir.actions.act_window.view">

            <field eval="1" name="sequence"/>

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

            <field name="view_id" ref="account.invoice_tree"/>

            <field name="act_window_id" ref="action_situation_invoice"/>

        </record>


        <record id="action_situation_invoice_view2" model="ir.actions.act_window.view">

            <field eval="2" name="sequence"/>

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

            <field name="view_id" ref="account.invoice_form"/>

            <field name="act_window_id" ref="action_situation_invoice"/>

        </record>

Now what i want is when in tree field i want to show 

Now, i want to show the two fields amount_net_ht and previous_amount_ht (added in account.invoice.line) in invoice_line_ids when  invoice_type is progress_invoice and hide them when  invoice_type is simple_invoice. For that i added context in the action of Progress Invoice and using xpath i did:

<xpath expr="//form/sheet/notebook/page/field/tree/field[@name='price_subtotal']" position="after">

            <field name="cumulative_amount_ht" invisible="context.get('invoice_type','simple_invoice')"/>

                        <field name="previous_amount_ht" invisible="context.get('invoice_type','simple_invoice')"/>

                        <field name="amount_net_ht" invisible="context.get('invoice_type','simple_invoice')"/>

</xpath>


but this does not work, the two field are always shown in Simple invoice form ( not in progress invoice like i want)

I know i can achieve this by creating completely new form for Progress Invoice ( similar to the default odoo invoice form ) and adding to it the new fields but it would be a lot of duplicated code. So i want to achieve this with context if it is possible.

Thanks. 

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

Problem solved, from here i get the answer : http://vitraining.com/show-hide-columns-in-openerp-tree-view-xml/

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

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

ลงชื่อ
Related Posts ตอบกลับ มุมมอง กิจกรรม
Chinese(HK) Language Pack แก้ไขแล้ว
openerp odoo10.0
อวตาร
อวตาร
1
ต.ค. 18
7627
count number of records based on condition แก้ไขแล้ว
odoo10.0
อวตาร
อวตาร
1
พ.ย. 24
21091
How to install odoo 10 in ubuntu 20.04? แก้ไขแล้ว
odoo10.0
อวตาร
อวตาร
1
ก.ย. 23
3919
Create selection type field dynamically?
openerp
อวตาร
อวตาร
อวตาร
2
ก.ย. 23
8517
Question about action_confirm
odoo10.0
อวตาร
อวตาร
อวตาร
3
พ.ค. 23
6497
คอมมูนิตี้
  • บทเรียน
  • เอกสารกำกับโปรแกรม
  • ฟอรั่ม
โอเพนซอร์ส
  • ดาวน์โหลด
  • 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