Skip to Content
Odoo Menu
  • Log ind
  • Prøv gratis
  • Apps
    Økonomi
    • Bogføring
    • Fakturering
    • Udgifter
    • Regneark (BI)
    • Dokumenter
    • e-Signatur
    Salg
    • CRM
    • Salg
    • POS Butik
    • POS Restaurant
    • Abonnementer
    • Udlejning
    Hjemmeside
    • Hjemmesidebygger
    • e-Handel
    • Blog
    • Forum
    • LiveChat
    • e-Læring
    Forsyningskæde
    • Lagerbeholdning
    • Produktion
    • PLM
    • Indkøb
    • Vedligeholdelse
    • Kvalitet
    HR
    • Medarbejdere
    • Rekruttering
    • Fravær
    • Medarbejdersamtaler
    • Anbefalinger
    • Flåde
    Marketing
    • Markedsføring på sociale medier
    • E-mailmarketing
    • SMS-marketing
    • Arrangementer
    • Automatiseret marketing
    • Spørgeundersøgelser
    Tjenester
    • Projekt
    • Timesedler
    • Udkørende Service
    • Kundeservice
    • Planlægning
    • Aftaler
    Produktivitet
    • Dialog
    • Godkendelser
    • IoT
    • VoIP
    • Vidensdeling
    • WhatsApp
    Tredjepartsapps Odoo Studio Odoo Cloud-platform
  • Brancher
    Detailhandel
    • Boghandel
    • Tøjforretning
    • Møbelforretning
    • Dagligvarebutik
    • Byggemarked
    • Legetøjsforretning
    Mad og værtsskab
    • Bar og pub
    • Restaurant
    • Fastfood
    • Gæstehus
    • Drikkevareforhandler
    • Hotel
    Ejendom
    • Ejendomsmægler
    • Arkitektfirma
    • Byggeri
    • Ejendomsadministration
    • Havearbejde
    • Boligejerforening
    Rådgivning
    • Regnskabsfirma
    • Odoo-partner
    • Marketingbureau
    • Advokatfirma
    • Rekruttering
    • Audit & certificering
    Produktion
    • Tekstil
    • Metal
    • Møbler
    • Fødevareproduktion
    • Bryggeri
    • Firmagave
    Heldbred & Fitness
    • Sportsklub
    • Optiker
    • Fitnesscenter
    • Kosmetolog
    • Apotek
    • Frisør
    Håndværk
    • Handyman
    • IT-hardware og support
    • Solenergisystemer
    • Skomager
    • Rengøringsservicer
    • VVS- og ventilationsservice
    Andet
    • Nonprofitorganisation
    • Miljøagentur
    • Udlejning af billboards
    • Fotografi
    • Cykeludlejning
    • Softwareforhandler
    Gennemse alle brancher
  • Community
    Få mere at vide
    • Tutorials
    • Dokumentation
    • Certificeringer
    • Oplæring
    • Blog
    • Podcast
    Bliv klogere
    • Udannelselsesprogram
    • Scale Up!-virksomhedsspillet
    • Besøg Odoo
    Få softwaren
    • Download
    • Sammenlign versioner
    • Udgaver
    Samarbejde
    • Github
    • Forum
    • Arrangementer
    • Oversættelser
    • Bliv partner
    • Tjenester til partnere
    • Registrér dit regnskabsfirma
    Modtag tjenester
    • Find en partner
    • Find en bogholder
    • Kontakt en rådgiver
    • Implementeringstjenester
    • Kundereferencer
    • Support
    • Opgraderinger
    Github Youtube Twitter LinkedIn Instagram Facebook Spotify
    +1 (650) 691-3277
    Få en demo
  • Prissætning
  • Hjælp

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

  • CRM
  • e-Commerce
  • Bogføring
  • Lager
  • PoS
  • Projekt
  • MRP
All apps
Du skal være registreret for at interagere med fællesskabet.
All Posts People Emblemer
Tags (View all)
odoo accounting v14 pos v15
Om dette forum
Du skal være registreret for at interagere med fællesskabet.
All Posts People Emblemer
Tags (View all)
odoo accounting v14 pos v15
Om dette forum
Hjælp

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

Tilmeld

Få besked, når der er aktivitet på dette indlæg

Dette spørgsmål er blevet anmeldt
openerpodoo10.0
14935 Visninger
Avatar
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
Avatar
Kassér
Wiem
Forfatter

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

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

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

Tilmeld dig
Related Posts Besvarelser Visninger Aktivitet
Chinese(HK) Language Pack Løst
openerp odoo10.0
Avatar
Avatar
1
okt. 18
7627
count number of records based on condition Løst
odoo10.0
Avatar
Avatar
1
nov. 24
21091
How to install odoo 10 in ubuntu 20.04? Løst
odoo10.0
Avatar
Avatar
1
sep. 23
3919
Create selection type field dynamically?
openerp
Avatar
Avatar
Avatar
2
sep. 23
8518
Question about action_confirm
odoo10.0
Avatar
Avatar
Avatar
3
maj 23
6500
Community
  • Tutorials
  • Dokumentation
  • Forum
Open Source
  • Download
  • Github
  • Runbot
  • Oversættelser
Tjenester
  • Odoo.sh-hosting
  • Support
  • Opgradere
  • Individuelt tilpasset udvikling
  • Uddannelse
  • Find en bogholder
  • Find en partner
  • Bliv partner
Om os
  • Vores virksomhed
  • Brandaktiver
  • Kontakt os
  • Stillinger
  • Arrangementer
  • Podcast
  • Blog
  • Kunder
  • Juridiske dokumenter • Privatlivspolitik
  • Sikkerhedspolitik
الْعَرَبيّة 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 er en samling open source-forretningsapps, der dækker alle dine virksomhedsbehov – lige fra CRM, e-handel og bogføring til lagerstyring, POS, projektledelse og meget mere.

Det unikke ved Odoo er, at systemet både er brugervenligt og fuldt integreret.

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