Odoo Help


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

on 1/22/15, 2:15 AM 1,218 views

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:


    <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">


                        <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" />


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

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


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


                                <group string="Dates"

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

                                    <field name="date_from" />

                                    <field name="date_to" />


                                <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)]" />



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

                                <field name="journal_ids" />




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

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


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


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

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

                            type="object" />







         <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>


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

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

            sequence="11" />


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))



#           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


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.

on 9/5/15, 7:09 AM

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, }

on 9/5/15, 7:12 AM

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.

on 9/5/15, 7:31 AM

Ben Bernard

--Ben Bernard--

| 4 3 6
Jakarta, Indonesia
--Ben Bernard--
Ben Bernard
On 1/23/15, 4:18 AM

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

@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.

on 1/23/15, 6:12 AM



| 5 3 6
Jakarta, Indonesia
On 1/22/15, 4:46 AM

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.

i'll try this Ivan thanks.

on 1/22/15, 5:26 AM

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.

on 1/22/15, 5:31 AM

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

on 1/22/15, 10:45 PM

About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.


Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

1 follower(s)


Asked: 1/22/15, 2:15 AM
Seen: 1218 times
Last updated: 9/5/15, 7:31 AM