Odoo Help

Welcome!

This community 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.

0

TypeError: argument of type 'bool' is not iterable

By
Ademola Oke
on 3/11/14, 11:42 PM 4,271 views

I'm trying to develop a new module to inherit and customize the partner module to add some new fields and functionality. It installs successfully but I get this error when I click the menu.

Client Traceback (most recent call last):
  File "C:\Program Files (x86)\OpenERP 7.0\Server\server\openerp\addons\web\http.py", line 204, in dispatch
  File "C:\Program Files (x86)\OpenERP 7.0\Server\server\openerp\addons\web\controllers\main.py", line 1128, in call_kw
  File "C:\Program Files (x86)\OpenERP 7.0\Server\server\openerp\addons\web\controllers\main.py", line 1120, in _call_kw
  File "C:\Program Files (x86)\OpenERP 7.0\Server\server\openerp\addons\web\session.py", line 42, in proxy
  File "C:\Program Files (x86)\OpenERP 7.0\Server\server\openerp\addons\web\session.py", line 30, in proxy_method
  File "C:\Program Files (x86)\OpenERP 7.0\Server\server\openerp\addons\web\session.py", line 103, in send


Server Traceback (most recent call last):
  File "C:\Program Files (x86)\OpenERP 7.0\Server\server\openerp\addons\web\session.py", line 89, in send
  File "C:\Program Files (x86)\OpenERP 7.0\Server\server\.\openerp\netsvc.py", line 292, in dispatch_rpc
  File "C:\Program Files (x86)\OpenERP 7.0\Server\server\.\openerp\service\web_services.py", line 626, in dispatch
  File "C:\Program Files (x86)\OpenERP 7.0\Server\server\.\openerp\osv\osv.py", line 188, in execute_kw
  File "C:\Program Files (x86)\OpenERP 7.0\Server\server\.\openerp\osv\osv.py", line 131, in wrapper
  File "C:\Program Files (x86)\OpenERP 7.0\Server\server\.\openerp\osv\osv.py", line 197, in execute
  File "C:\Program Files (x86)\OpenERP 7.0\Server\server\openerp\addons\audittrail\audittrail.py", line 514, in execute_cr
  File "C:\Program Files (x86)\OpenERP 7.0\Server\server\.\openerp\osv\osv.py", line 185, in execute_cr
  File "C:\Program Files (x86)\OpenERP 7.0\Server\server\openerp\addons\base\res\res_partner.py", line 312, in fields_view_get
  File "C:\Program Files (x86)\OpenERP 7.0\Server\server\.\openerp\osv\orm.py", line 2300, in fields_view_get
  File "C:\Program Files (x86)\OpenERP 7.0\Server\server\.\openerp\osv\orm.py", line 2285, in clean
TypeError: argument of type 'bool' is not iterable

This is the code I'm using:

class res_partner(osv.osv):
    _description = 'Tax Payer'
    _inherit = 'res.partner'

    _order = "name"
    _columns = {            
        'name': fields.char('Name', size=128, required=True, select=True),
        'last_name': fields.char('Last Name', size=128, required=True),  
        'first_name': fields.char('First Name', size=128, required=True),
        'other_name': fields.char('Other Name', size=128),  
        'taxpayer': fields.boolean('Taxpayer', help="Check this box if this contact is a Tax Payer."),
        'cust_ref': fields.char('Customer Reference', size=64, select=1),
        'cust_ref_alt': fields.char('Alternative Customer Reference', size=64),
        'cust_ref_desc': fields.char('Customer Reference Description', size=64),
        'source_income': fields.char('Source of Income', size=255),
        'taxpayer_type': fields.selection([('individual','Individual'),('headquarters','Headquarters'),('branch','Branch')], 'Taxpayer Type'),
        'line_business': fields.char('Line of Business', size=255), 
        'registration_date': fields.date('Registration Date'),   
        'jtb_tin': fields.char('JTB Tax Identification Number', size=32), 
        #'state_tax_id': fields.char('Temp Tax Id', size=64),         
        'temp_tax_id': fields.char('Temp Id', size=64),    
        'uploaded': fields.boolean('Uploaded', help="Customer data upload uses this to determine if the record should be uploaded or not."),   
    }   

    _defaults = {           
        'uploaded': False,
        'taxpayer': False,
        'customer': False,       
        'is_company': True,
        'taxpayer_type': "headquarters", 
    }   

    _sql_constraints = [  
         ('jtb_tin', 'unique(jtb_tin)', 'The JTB TIN must be unique for each tax payer!'),
         ('temp_tax_id', 'unique(temp_tax_id)', 'The temporary tax Id must be unique for each tax payer!'),
    ]

    def onchange_individual_name(self, cr, uid, ids, last_name, first_name, other_name, context=None):
      taxpayer = ""
      if first_name:
        taxpayer_name = str(first_name) 
        if last_name:
          taxpayer_name = str(first_name) + " " + str(last_name)
          if other_name:
            taxpayer_name = str(first_name) + " " + str(other_name) + " " + str(last_name)    
      return {'value':{'name': taxpayer_name}}

    def onchange_name(self, cr, uid, ids, name, last_name="", first_name="", other_name="", context=None):
        return {'value':{'first_name': str(name),'last_name':"_"}}     

    def create(self, cr, uid, vals, context=None):
        temp_id = self.pool.get('ir.sequence').get(cr, uid, 'temp.tax.id')
        vals['temp_tax_id'] = temp_id
        vals['jtb_tin'] = temp_id
        return super(res_partner, self).create(cr, uid, vals, context=context) 

    def write(self, cr, uid, ids, vals, context=None):
        vals['uploaded'] = False
        return super(res_partner,self).write(cr, uid, ids, vals, context=context)

The view is like this:

<?xml version="1.0" encoding="utf-8"?>
<openerp>
    <data>

        <!-- Views --> 

        <!-- Tax Payer List View -->

        <record id="view_taxpayer_list" model="ir.ui.view">
          <field name="name">res.taxpayer.list</field>
          <field name="model">res.partner</field>
          <field eval="1" name="priority"/>
          <field name="arch" type="xml">
            <tree string="Contacts">
                <field name="name"/>
                <field name="jtb_tin" string="TIN"/>  
                <field name="temp_tax_id" string="Temp Tax Id"/>
                <field name="city"/>
                <field name="phone"/>
                <field name="email"/>
                <field name="taxpayer_type" string="Type"/>                                                  
                <!--<field name="taxpayer" groups="base.group_no_one"/>                                       
                <field name="uploaded" groups="base.group_no_one"/>-->  
            </tree>
          </field>
        </record>  

        <!-- Tax Payer Form View -->

        <record id="view_taxpayer_form" model="ir.ui.view">
          <field name="name">res.taxpayer.form</field>
          <field name="model">res.partner</field>  
          <field eval="0" name="priority"/>
          <field name="arch" type="xml">
            <form string="Tax Payer" version="7.0">
                <sheet>
                    <field name="image" widget='image' class="oe_left oe_avatar" options='{"preview_image": "image_medium", "size": [90, 90]}'/>
                    <div class="oe_title">
                        <div class="oe_edit_only"> 
                            <!--                                              
                            <field name="uploaded" groups="base.group_no_one"/> 
                            <label for="uploaded" string="Uploaded?" groups="base.group_no_one"/>                                             
                            <field name="taxpayer" groups="base.group_no_one"/> 
                            <label for="taxpayer" string="Is a Tax Payer?" groups="base.group_no_one"/>
                            -->
                            <field name="taxpayer_type" placeholder="Type..."/>
                            <field name="is_company" on_change="onchange_type(is_company)" class="oe_inline" invisible="1"/> 
                            <label for="is_company" string="Is a Company?" invisible="1"/>
                        </div>
                        <h1>
                            <field name="name" placeholder="Name" invisible="1"/>   
                            <field name="first_name"  default_focus="1" placeholder="First Name" on_change="onchange_individual_name(last_name, first_name, other_name)"/>      
                            <field name="last_name" default_focus="1" placeholder="Last Name" on_change="onchange_individual_name(last_name, first_name, other_name)"/>
                            <field name="other_name" placeholder="Other Name" on_change="onchange_individual_name(last_name, first_name, other_name)"/>
                        </h1>                   
                        <field name="jtb_tin" placeholder="JTB TIN..."/>    
                        <field name="temp_tax_id" string="Temp Tax Id" placeholder="Temp Tax Id..."/>
                        <field name="category_id" widget="many2many_tags" placeholder="Tags..." invisible="1"/>
                    </div>
                    <div class="oe_right oe_button_box" name="buttons"> </div>

                    <group>
                        <group>
                            <label for="type" attrs="{'invisible': [('parent_id','=', False)]}"/>
                            <div attrs="{'invisible': [('parent_id','=', False)]}" name="div_type">
                                <field class="oe_inline" name="type"/>
                                <label for="use_parent_address" class="oe_edit_only"/>
                                <field name="use_parent_address" class="oe_edit_only oe_inline" on_change="onchange_address(use_parent_address, parent_id)"/>
                            </div>

                            <label for="street" string="Address"/>
                            <div>
                                <field name="street" placeholder="Street..."/>
                                <field name="street2"/>
                                <div class="address_format">
                                    <field name="city" placeholder="City" style="width: 40%%" attrs="{'readonly': [('use_parent_address','=',True)]}"/>
                                    <field name="state_id" class="oe_no_button" placeholder="State" style="width: 37%%" options='{"no_open": True}' on_change="onchange_state(state_id)" attrs="{'readonly': [('use_parent_address','=',True)]}"/>
                                    <field name="zip" placeholder="ZIP" style="width: 20%%" attrs="{'readonly': [('use_parent_address','=',True)]}"/>
                                </div>
                                <field name="country_id" placeholder="Country" class="oe_no_button" options='{"no_open": True}' attrs="{'readonly': [('use_parent_address','=',True)]}"/>
                            </div>
                            <field name="email" widget="email"/>
                            <field name="website" widget="url" attrs="{'invisible': [('taxpayer_type','=', 'individual')]}"/>
                        </group>
                        <group>
                            <field name="title" domain="[('domain', '=', 'contact')]" options="{'no_open': True}" attrs="{'invisible': [('taxpayer_type','!=', 'individual')]}"/>     
                            <field name="parent_id" placeholder="Employer" domain="[('taxpayer_type', '!=', 'headquarters')]" context="{'default_taxpayer_type': 'individual'}" attrs="{'invisible': [('taxpayer_type','!=', 'individual')]}" on_change="onchange_address(use_parent_address, parent_id)" invisible="0"/>
                            <field name="source_income" attrs="{'invisible': [('taxpayer_type','!=', 'individual')]}"> </field>
                            <field name="function" placeholder="e.g. Sales Director" attrs="{'invisible': [('taxpayer_type','!=', 'individual')]}"/>
                            <field name="phone" placeholder="e.g. +234806....."/>
                            <field name="mobile"/>
                            <field name="fax"/>
                        </group>
                    </group>

                    <notebook colspan="4">
                        <page string="Contacts" attrs="{'invisible': [('taxpayer_type','=', 'individual')]}" autofocus="autofocus">
                            <field name="child_ids" context="{'default_parent_id': active_id}" mode="kanban">
                                <kanban>
                                    <field name="color"/>
                                    <field name="name"/>
                                    <field name="title"/>
                                    <field name="email"/>
                                    <field name="parent_id"/>
                                    <field name="is_company"/>
                                    <field name="function"/>
                                    <field name="phone"/>
                                    <field name="street"/>
                                    <field name="street2"/>
                                    <field name="zip"/>
                                    <field name="city"/>
                                    <field name="country_id"/>
                                    <field name="mobile"/>
                                    <field name="fax"/>
                                    <field name="state_id"/>
                                    <field name="has_image"/>
                                    <templates>
                                        <t t-name="kanban-box">
                                            <t t-set="color" t-value="kanban_color(record.color.raw_value)"/>
                                            <div t-att-class="color + (record.title.raw_value == 1 ? ' oe_kanban_color_alert' : '')" style="position: relative">
                                                <a t-if="! read_only_mode" type="delete" style="position: absolute; right: 0; padding: 4px; diplay: inline-block">X</a>
                                                <div class="oe_module_vignette">
                                                <a type="open">
                                                    <t t-if="record.has_image.raw_value === true">
                                                        <img t-att-src="kanban_image('res.partner', 'image', record.id.value, {'preview_image': 'image_small'})" class="oe_avatar oe_kanban_avatar_smallbox"/>
                                                    </t>
                                                    <t t-if="record.image and record.image.raw_value !== false">
                                                        <img t-att-src="'data:image/png;base64,'+record.image.raw_value" class="oe_avatar oe_kanban_avatar_smallbox"/>
                                                    </t>
                                                    <t t-if="record.has_image.raw_value === false and (!record.image or record.image.raw_value === false)">
                                                        <t t-if="record.is_company.raw_value === 'true'">
                                                            <img t-att-src="_s + '/base/static/src/img/company_image.png'" class="oe_kanban_image oe_kanban_avatar_smallbox"/>
                                                        </t>
                                                        <t t-if="record.is_company.raw_value === 'false'">
                                                            <img t-att-src="_s + '/base/static/src/img/avatar.png'" class="oe_kanban_image oe_kanban_avatar_smallbox"/>
                                                        </t>
                                                    </t>
                                                </a>
                                                    <div class="oe_module_desc">
                                                        <div class="oe_kanban_box_content oe_kanban_color_bglight oe_kanban_color_border">
                                                            <table class="oe_kanban_table">
                                                                <tr>
                                                                    <td class="oe_kanban_title1" align="left" valign="middle">
                                                                        <h4><a type="open"><field name="name"/></a></h4>
                                                                        <i><div t-if="record.function.raw_value">
                                                                            <field name="function"/></div></i>
                                                                        <div><a t-if="record.email.raw_value" title="Mail" t-att-href="'mailto:'+record.email.value">
                                                                            <field name="email"/>
                                                                        </a></div>
                                                                        <div t-if="record.phone.raw_value">Phone: <field name="phone"/></div>
                                                                        <div t-if="record.mobile.raw_value">Mobile: <field name="mobile"/></div>
                                                                        <div t-if="record.fax.raw_value">Fax: <field name="fax"/></div>
                                                                    </td>
                                                                </tr>
                                                            </table>
                                                        </div>
                                                    </div>
                                                </div>
                                            </div>
                                        </t>
                                    </templates>
                                </kanban>
                                <form string="Contact" version="7.0">
                                    <sheet>
                                        <field name="image" widget='image' class="oe_avatar oe_left" options='{"preview_image": "image_medium"}'/>
                                        <div class="oe_title">
                                            <label for="name" class="oe_edit_only"/>
                                            <h1><field name="name" style="width: 70%%"/></h1>
                                            <field name="category_id" widget="many2many_tags" placeholder="Tags..." style="width: 70%%"/>
                                        </div>
                                        <group>
                                            <field name="name"/>
                                            <field name="category_id" widget="many2many_tags" placeholder="Tags..."/>
                                            <field name="function" placeholder="e.g. Sales Director"/>
                                            <field name="email"/>
                                            <field name="phone"/>
                                            <field name="mobile"/>
                                        </group>
                                    </sheet>
                                </form>
                            </field>
                        </page>
                        <page string="Notes">
                            <field name="comment" placeholder="Put an internal note..."/>
                        </page>
                        <!-- The History page becomes visible as soon as there is something to display inside -->
                        <page string="History" name="page_history" invisible="True">
                        </page>
                    </notebook>
                </sheet>
              </form> 
          </field>
        </record>

        <record id="view_res_taxpayer_filter" model="ir.ui.view">
            <field name="name">res.partner.select</field>
            <field name="model">res.partner</field>
            <field name="arch" type="xml">
                <search string="Search Tax Payer">
                   <field name="name" filter_domain="['|','|',('name','ilike',self),('parent_id','ilike',self),('ref','=',self)]"/>
                   <separator/>
                   <filter string="Persons" name="type_person" domain="[('taxpayer_type','=','individual')]"/>
                   <filter string="Companies" name="type_company" domain="['|', ('taxpayer_type','=','headquarters'), ('taxpayer_type','=','branch')]"/>            
                   <group expand="0" string="Group By...">
                       <filter string="Type" context="{'group_by': 'taxpayer_type'}"/>
                       <filter string="City" context="{'group_by': 'city'}"/>
                   </group>
               </search>
            </field>
        </record>  

        <!-- Menus -->

        <!-- Tax Payer Menu -->  

        <record id="action_tax_payer" model="ir.actions.act_window">
          <field name="name">Tax Payers</field>
          <field name="res_model">res.partner</field>
          <field name="view_type">form</field>
          <field name="view_mode">tree,form</field>  
          <field name="domain">[('taxpayer','=',1)]</field>
          <field name="context">{'default_taxpayer':1, 'search_default_taxpayer':1}</field>
          <field name="search_view_id" ref="view_res_taxpayer_filter"/>
          <field name="view_id" ref="view_taxpayer_list"/>
        </record>

        <menuitem action="action_tax_payer" id="account_tax_payer_list" parent="menu_bank_payments" sequence="25" groups="account_collections.group_collections_officer,account_collections.group_collections_manager,account_collections.group_chairman,base.group_no_one"/>

        <!-- Tax Payer Sequence 

        <record id="sequence_taxpayer" model="ir.sequence.type">
            <field name="name">Temp Tax Id</field>
            <field name="code">temp.tax.id</field>
        </record>
        <record id="sequence_reconcile_seq" model="ir.sequence">
            <field name="name">Temporary Tax Id</field>
            <field name="code">temp.tax.id</field>
            <field name="prefix">TMP</field>
            <field eval="106080" name="number_next"/>
            <field eval="1" name="number_increment"/>
            <field eval="5" name="padding"/>
        </record>   
        -->
    </data>
</openerp>

When I try to uninstall the module, I get this error:

Client Traceback (most recent call last):
  File "C:\Program Files (x86)\OpenERP 7.0\Server\server\openerp\addons\web\http.py", line 204, in dispatch
  File "C:\Program Files (x86)\OpenERP 7.0\Server\server\openerp\addons\web\controllers\main.py", line 1132, in call_button
  File "C:\Program Files (x86)\OpenERP 7.0\Server\server\openerp\addons\web\controllers\main.py", line 1120, in _call_kw
  File "C:\Program Files (x86)\OpenERP 7.0\Server\server\openerp\addons\web\session.py", line 42, in proxy
  File "C:\Program Files (x86)\OpenERP 7.0\Server\server\openerp\addons\web\session.py", line 30, in proxy_method
  File "C:\Program Files (x86)\OpenERP 7.0\Server\server\openerp\addons\web\session.py", line 103, in send


Server Traceback (most recent call last):
  File "C:\Program Files (x86)\OpenERP 7.0\Server\server\openerp\addons\web\session.py", line 89, in send
  File "C:\Program Files (x86)\OpenERP 7.0\Server\server\.\openerp\netsvc.py", line 292, in dispatch_rpc
  File "C:\Program Files (x86)\OpenERP 7.0\Server\server\.\openerp\service\web_services.py", line 626, in dispatch
  File "C:\Program Files (x86)\OpenERP 7.0\Server\server\.\openerp\osv\osv.py", line 188, in execute_kw
  File "C:\Program Files (x86)\OpenERP 7.0\Server\server\.\openerp\osv\osv.py", line 131, in wrapper
  File "C:\Program Files (x86)\OpenERP 7.0\Server\server\.\openerp\osv\osv.py", line 197, in execute
  File "C:\Program Files (x86)\OpenERP 7.0\Server\server\openerp\addons\audittrail\audittrail.py", line 514, in execute_cr
  File "C:\Program Files (x86)\OpenERP 7.0\Server\server\.\openerp\osv\osv.py", line 185, in execute_cr
  File "C:\Program Files (x86)\OpenERP 7.0\Server\server\openerp\addons\base\module\module.py", line 495, in button_immediate_uninstall
  File "C:\Program Files (x86)\OpenERP 7.0\Server\server\openerp\addons\base\module\module.py", line 475, in _button_immediate_function
  File "C:\Program Files (x86)\OpenERP 7.0\Server\server\.\openerp\pooler.py", line 39, in restart_pool
  File "C:\Program Files (x86)\OpenERP 7.0\Server\server\.\openerp\modules\registry.py", line 219, in new
  File "C:\Program Files (x86)\OpenERP 7.0\Server\server\.\openerp\modules\loading.py", line 421, in load_modules
  File "C:\Program Files (x86)\OpenERP 7.0\Server\server\openerp\addons\base\module\module.py", line 439, in module_uninstall
  File "C:\Program Files (x86)\OpenERP 7.0\Server\server\openerp\addons\base\ir\ir_model.py", line 536, in _module_data_uninstall
AttributeError: 'NoneType' object has no attribute '_table'

Can anyone please detect the problem?

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

0 follower(s)

Stats

Asked: 3/11/14, 11:42 PM
Seen: 4271 times
Last updated: 3/16/15, 8:10 AM