Skip to Content
Odoo Menú
  • Registra entrada
  • Prova-ho gratis
  • Aplicacions
    Finances
    • Comptabilitat
    • Facturació
    • Despeses
    • Full de càlcul (IA)
    • Documents
    • Signatura
    Vendes
    • CRM
    • Vendes
    • Punt de venda per a botigues
    • Punt de venda per a restaurants
    • Subscripcions
    • Lloguer
    Imatges de llocs web
    • Creació de llocs web
    • Comerç electrònic
    • Blog
    • Fòrum
    • Xat en directe
    • Aprenentatge en línia
    Cadena de subministrament
    • Inventari
    • Fabricació
    • PLM
    • Compres
    • Manteniment
    • Qualitat
    Recursos humans
    • Empleats
    • Reclutament
    • Absències
    • Avaluacions
    • Recomanacions
    • Flota
    Màrqueting
    • Màrqueting Social
    • Màrqueting per correu electrònic
    • Màrqueting per SMS
    • Esdeveniments
    • Automatització del màrqueting
    • Enquestes
    Serveis
    • Projectes
    • Fulls d'hores
    • Servei de camp
    • Suport
    • Planificació
    • Cites
    Productivitat
    • Converses
    • Validacions
    • IoT
    • VoIP
    • Coneixements
    • WhatsApp
    Aplicacions de tercers Odoo Studio Plataforma d'Odoo al núvol
  • Sectors
    Comerç al detall
    • Llibreria
    • Botiga de roba
    • Botiga de mobles
    • Botiga d'ultramarins
    • Ferreteria
    • Botiga de joguines
    Food & Hospitality
    • Bar i pub
    • Restaurant
    • Menjar ràpid
    • Guest House
    • Distribuïdor de begudes
    • Hotel
    Immobiliari
    • Agència immobiliària
    • Estudi d'arquitectura
    • Construcció
    • Gestió immobiliària
    • Jardineria
    • Associació de propietaris de béns immobles
    Consultoria
    • Empresa comptable
    • Partner d'Odoo
    • Agència de màrqueting
    • Bufet d'advocats
    • Captació de talent
    • Auditoria i certificació
    Fabricació
    • Textile
    • Metal
    • Mobles
    • Menjar
    • Brewery
    • Regals corporatius
    Salut i fitness
    • Club d'esport
    • Òptica
    • Centre de fitness
    • Especialistes en benestar
    • Farmàcia
    • Perruqueria
    Trades
    • Servei de manteniment
    • Hardware i suport informàtic
    • Sistemes d'energia solar
    • Shoe Maker
    • Serveis de neteja
    • Instal·lacions HVAC
    Altres
    • Nonprofit Organization
    • Agència del medi ambient
    • Lloguer de panells publicitaris
    • Fotografia
    • Lloguer de bicicletes
    • Distribuïdors de programari
    Browse all Industries
  • Comunitat
    Aprèn
    • Tutorials
    • Documentació
    • Certificacions
    • Formació
    • Blog
    • Pòdcast
    Potenciar l'educació
    • Programa educatiu
    • Scale-Up! El joc empresarial
    • Visita Odoo
    Obtindre el programari
    • Descarregar
    • Comparar edicions
    • Novetats de les versions
    Col·laborar
    • GitHub
    • Fòrum
    • Esdeveniments
    • Traduccions
    • Converteix-te en partner
    • Services for Partners
    • Registra la teva empresa comptable
    Obtindre els serveis
    • Troba un partner
    • Troba un comptable
    • Contacta amb un expert
    • Serveis d'implementació
    • Referències del client
    • Suport
    • Actualitzacions
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Programar una demo
  • Preus
  • Ajuda

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

  • CRM
  • e-Commerce
  • Comptabilitat
  • Inventari
  • PoS
  • Projectes
  • MRP
All apps
You need to be registered to interact with the community.
All Posts People Badges
Etiquetes (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
Etiquetes (View all)
odoo accounting v14 pos v15
About this forum
Ajuda

how to return different views in a method? Please someone help me.. Thanks in advance

Subscriure's

Get notified when there's activity on this post

This question has been flagged
2 Respostes
6870 Vistes
Avatar
Alcaline

I've created a wizard that views the account.move.line and i want the data of this to be filter by DATE, PERIOD, and FISCAL YEAR using the domain. but when i run it, it does not pop up the wizard and automatically close the whole wizard. Can someone please help me in this problem?

 

Here is my code:

.xml:

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

            <field name="name">Extended Tax Report</field>

            <field name="model">biz1.tax.report</field>

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

                <form string="Filter" version="7.0">

                    <sheet>

                        <label string="" />  <!-- binding for inherited views -->

                        <group col="4">

                            <field name="chart_account_id" widget='selection'

                                on_change="onchange_chart_id(chart_account_id, context)" />

                            <field name="company_id" invisible="1" />

                            <field name="fiscalyear_id" domain="[('company_id','=',company_id)]" />

                            <field name="target_move" />

                        </group>

                        <notebook tabpos="up" colspan="4">

                            <page string="Filters" name="filters">

                                <group>

                                    <field name="filter" on_change="onchange_filter(filter, fiscalyear_id)" />

                                </group>

                                <group string="Dates"

                                    attrs="{'invisible':[('filter', '!=', 'filter_date')], 'required':[('filter', '=', 'filter_date')]}">

                                    <field name="date_from" />

                                    <field name="date_to" />

                                </group>

                                <group string="Periods"

                                    attrs="{'invisible':[('filter','!=','filter_period')], 'required':[('filter', '=', 'filter_period')]}">

                                    <field name="period_from" domain="[('fiscalyear_id', '=', fiscalyear_id)]" />

                                    <field name="period_to" domain="[('fiscalyear_id', '=', fiscalyear_id)]" />

                                </group>

                            </page>

                            <page string="Journals" name="journal_ids">

                                <field name="journal_ids" />

                            </page>

                        </notebook>

                        <footer>

                            <button name="check_report" string="Print" type="object"

                                default_focus="1" class="oe_highlight" />

                            or

                            <button string="Cancel" class="oe_link" special="cancel" />

                        </footer>

                        <button icon="gtk-cancel" special="cancel" string="Cancel" />

                        <button icon="gtk-ok" name="action_button_ok" string="Filter Data"

                            type="object" />

                    </sheet>

                </form>

            </field>

        </record>

        

        

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

            <field name="name">Extended Tax Report</field>

            <field name="res_model">biz1.tax.report</field>

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

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

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

            <field name="target">new</field>

        </record>

        <menuitem icon="STOCK_JUSTIFY_FILL" name="Tax Report" id="menu_tax_report"

            parent="account.menu_finance_entries" action="action_tax_reports"

            sequence="11" />

.py

def action_button_ok(self, cr, uid, ids, context=None):

      account_ids = []

      account_tax_ids = self.pool.get('account.tax').search(cr,uid,[('id','!=',0)],context= context)

      netsvc.Logger().notifyChannel("\n0000000000  ", netsvc.LOG_INFO, ''+str(account_tax_ids))

      for account_tax in self.pool.get('account.tax').browse(cr,uid,account_tax_ids,context=context):

          netsvc.Logger().notifyChannel("\n111111111  ", netsvc.LOG_INFO, ''+str(account_tax))

          account_ids.append(account_tax.account_collected_id.id)

          account_ids.append(account_tax.account_paid_id.id)

#           netsvc.Logger().notifyChannel("\n  ", netsvc.LOG_INFO, ''+str(finish))

      action1 = []  

      for wizard in self.browse(cr,uid,ids, context=context):

          netsvc.Logger().notifyChannel("\n222222  ", netsvc.LOG_INFO, ''+str(account_tax))

         

          if wizard.filter == 'date':

               netsvc.Logger().notifyChannel("\n333333333  ", netsvc.LOG_INFO, ''+str(wizard.search_selection))

               action1 = {

                    'type': 'ir.actions.act_window',

                    'res_model': 'account.move.line',

                    'view_mode': 'tree',

                    'view_type': 'tree',

                    'domain':[('date','>=',wizard.date_from), ('date', '<=', wizard.date_to)] ,

                    'views': [(False, 'tree')],

                    'target': 'new',

                     }

              

          elif wizard.filter == 'period':

          

              action1= {

                    'type': 'ir.actions.act_window',

                    'res_model': 'account.move.line',

                    'view_mode': 'tree',

                    'view_type': 'tree',

                    'domain':[('period_id','>=',wizard.period_from), ('period_id','<=',wizard.period_to)] ,

                    'views': [(False, 'tree')],

                    'target': 'new',

                     }

        

          return action1

   

0
Avatar
Descartar
Aldennis

I've done this before but using a different approach. In your .py file, using search function, get all the record ids of the account_move_line records that you want to display. Filter it according to your needs (i.e. Date, Period and Fiscal Year) and put all of these ids in one list (move_line_ids). Then in your action1 domain put: [('id','in',(move_line_ids))], Make your 'target':'current'. Hope this helps.

Aldennis

This is my return method: return { 'name':_(title), 'view_mode': 'tree', 'view_id': view_id, 'view_type': 'form', 'res_model': 'account.move.line', 'type': 'ir.actions.act_window', 'nodestroy': True, 'target': 'current', 'domain': [('id','in',(move_line_ids))], 'context': {}, 'limit': limit, }

Aldennis

The 'limit' attribute is optional. In my case, I want to display all records in one page if it is greater than 80. You also need to have both 'view_mode' and 'view_type' included in your return.

Avatar
Ivan
Best Answer

You have to have an else in the if-elif structure just in case.

AFAIK you need to put form,tree in the view_mode (tree alone does not work).

'views': [(False, 'tree')] is not required if you don't have specific view to call.

In general, check that your return value is a proper action call.

0
Avatar
Descartar
Alcaline
Autor

i'll try this Ivan thanks.

Alcaline
Autor

hi Ivan i've already try this one but nothing happen. the output is still the same. the wizard is automatically closing. when i click the button.

Ivan

Can you post what is returned from that method? Log the return value before the return statement.

Avatar
Ben Bernard
Best Answer

I think you forget to set the 'view_id' key for action dictionary.

0
Avatar
Descartar
Ivan

@Bernard view_id is not compulsory if you don't have any specific view in mind. It will just take the first view based on the model and type requested ordered by priority and then name.

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

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

Registrar-se
Community
  • Tutorials
  • Documentació
  • Fòrum
Codi obert
  • Descarregar
  • GitHub
  • Runbot
  • Traduccions
Serveis
  • Allotjament a Odoo.sh
  • Suport
  • Actualització
  • Desenvolupaments personalitzats
  • Educació
  • Troba un comptable
  • Troba un partner
  • Converteix-te en partner
Sobre nosaltres
  • La nostra empresa
  • Actius de marca
  • Contacta amb nosaltres
  • Llocs de treball
  • Esdeveniments
  • Pòdcast
  • Blog
  • Clients
  • Informació legal • Privacitat
  • Seguretat
الْعَرَبيّة 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 és un conjunt d'aplicacions empresarials de codi obert que cobreix totes les necessitats de la teva empresa: CRM, comerç electrònic, comptabilitat, inventari, punt de venda, gestió de projectes, etc.

La proposta única de valor d'Odoo és ser molt fàcil d'utilitzar i estar totalment integrat, ambdues alhora.

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