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.

1

TypeError: VARCHAR parameter should be an int, got <type 'set'> [Closed]

By
Atchuthan
on 5/15/13, 10:31 AM 2,301 views

The Question has been closed

by
Atchuthan
on 12/13/2013 00:53:19
**__init__.py:**
import test


**__openerp__.py:**
{
    "name" : "test",
    "version" : "0.1",
    "author" : "user",
    "category" : "Generic Modules/Others",
    "depends" : ["base"],
    "description" : "Simple demo form",
    "init_xml" : [],
    "demo_xml" : [],
    "data" : ["sample_view.xml"],
    "active": False,
    "installable": True
}

**sample.py:**

from osv import fields, osv
import time

class test(osv.osv):
    _name = "test"
    _description = "Simple Form"
    _columns = {
             'name':fields.char('Name', size=32, required=True),
             'amount': fields.integer('Amount'),
             'interest': fields.float('Interest'),
             'address': fields.text('Address'),
             'flag': fields.boolean('Flag'),
             'date': fields.date('Date'),
             'datetime': fields.datetime('Date with Time'),
             'confirm': fields.selection((('n', 'Unconfirmed'), ('c', 'Confirmed')),
                  'Selection Box'),
    }

test()




**sample_view.xml:**

<?xml version="1.0" encoding="utf-8"?>
<openerp>
    <data>
        <record model="ir.ui.view" id="test_tree_view">
            <field name="name">test.tree</field>
            <field name="model">test</field>
            <field name="type">tree</field>
            <field name="arch" type="xml">
                <tree string="test">
                    <field name="name"/>
                    <field name="address"/>
                    <field name="date"/>
                </tree>
            </field>
        </record>

        <record model="ir.ui.view" id="test_form_view">
            <field name="name">test.form</field>
            <field name="model">test</field>
            <field name="type">form</field>
            <field name="arch" type="xml">
                <form string="test">
                    <field name="name"/>
                    <field name="address"/>
                    <field name="date"/>
                </form>
            </field>
        </record>

        <record id="action_test_form" model="ir.actions.act_window">
        <field name="name">test</field>
        <field name="res_model">test</field>
        <field name="view_type">form</field>
        <field name="view_mode">tree,form</field>
        <field name="view_id" ref="test_tree_view"/>
        </record>

        <menuitem name="testParent" icon="terp-project" id="testParent_menu"/>

        <menuitem name="testChild" parent="testParent_menu" id="testChild_menu" />

        <menuitem name="Header" parent="testChild_menu" id="Header_menu_mainform" action="action_test_form"/>
    </data>
</openerp>

Log obtained from OpenERP Server:

OpenERP Server Error

Client Traceback (most recent call last):
  File "/var/app/openerp/web/addons/web/http.py", line 204, in dispatch
    response["result"] = method(self, **self.params)
  File "/var/app/openerp/web/addons/web/controllers/main.py", line 1133, in call_button
    action = self._call_kw(req, model, method, args, {})
  File "/var/app/openerp/web/addons/web/controllers/main.py", line 1121, in _call_kw
    return getattr(req.session.model(model), method)(*args, **kwargs)
  File "/var/app/openerp/web/addons/web/session.py", line 43, in proxy
    result = self.proxy.execute_kw(self.session._db, self.session._uid, self.session._password, self.model, method, args, kw)
  File "/var/app/openerp/web/addons/web/session.py", line 31, in proxy_method
    result = self.session.send(self.service_name, method, *args)
  File "/var/app/openerp/web/addons/web/session.py", line 104, in send
    raise xmlrpclib.Fault(openerp.tools.ustr(e), formatted_info)


Server Traceback (most recent call last):
  File "/var/app/openerp/web/addons/web/session.py", line 90, in send
    return openerp.netsvc.dispatch_rpc(service_name, method, args)
  File "/var/app/openerp/server/openerp/netsvc.py", line 293, in dispatch_rpc
    result = ExportService.getService(service_name).dispatch(method, params)
  File "/var/app/openerp/server/openerp/service/web_services.py", line 626, in dispatch
    res = fn(db, uid, *params)
  File "/var/app/openerp/server/openerp/osv/osv.py", line 188, in execute_kw
    return self.execute(db, uid, obj, method, *args, **kw or {})
  File "/var/app/openerp/server/openerp/osv/osv.py", line 131, in wrapper
    return f(self, dbname, *args, **kwargs)
  File "/var/app/openerp/server/openerp/osv/osv.py", line 197, in execute
    res = self.execute_cr(cr, uid, obj, method, *args, **kw)
  File "/var/app/openerp/server/openerp/osv/osv.py", line 185, in execute_cr
    return getattr(object, method)(cr, uid, *args, **kw)
  File "/var/app/openerp/server/openerp/addons/base/module/module.py", line 495, in button_immediate_uninstall
    return self._button_immediate_function(cr, uid, ids, self.button_uninstall, context=context)
  File "/var/app/openerp/server/openerp/addons/base/module/module.py", line 475, in _button_immediate_function
    _, pool = pooler.restart_pool(cr.dbname, update_module=True)
  File "/var/app/openerp/server/openerp/pooler.py", line 39, in restart_pool
    registry = RegistryManager.new(db_name, force_demo, status, update_module)
  File "/var/app/openerp/server/openerp/modules/registry.py", line 218, in new
    openerp.modules.load_modules(registry.db, force_demo, status, update_module)
  File "/var/app/openerp/server/openerp/modules/loading.py", line 348, in load_modules
    processed = load_marked_modules(cr, graph, states_to_load, force, status, report, loaded_modules, update_module)
  File "/var/app/openerp/server/openerp/modules/loading.py", line 259, in load_marked_modules
    loaded, processed = load_module_graph(cr, graph, progressdict, report=report, skip_modules=loaded_modules, perform_checks=perform_checks)
  File "/var/app/openerp/server/openerp/modules/loading.py", line 168, in load_module_graph
    init_module_models(cr, package.name, models)
  File "/var/app/openerp/server/openerp/modules/module.py", line 374, in init_module_models
    result = obj._auto_init(cr, {'module': module_name})
  File "/var/app/openerp/server/openerp/osv/orm.py", line 3154, in _auto_init
    cr.execute('ALTER TABLE "%s" ADD COLUMN "%s" %s' % (self._table, k, get_pg_type(f)[1]))
  File "/var/app/openerp/server/openerp/osv/orm.py", line 581, in get_pg_type
    pg_type = ('varchar', pg_varchar(f.size))
  File "/var/app/openerp/server/openerp/osv/orm.py", line 547, in pg_varchar
    % type(size))
TypeError: VARCHAR parameter should be an int, got <type 'set'>

Tell me what my problem is?

2
Carlos Llamacho
On 12/12/13, 2:04 PM

You have any other python code? I found this exact error on a py file in one of my modules that had a field with the size attribute declared incorrectly. It must be integer but i had it as a string, fixed it and solved in an instant.

'field_name': fields.char('Name', size="10") <---- Incorrect

'field_name': fields.char('Name', size=10) <---- Correct

Hope you fixed it.

5

Sandeep

--Sandeep--
6083
| 6 5 8
Delhi, India
--Sandeep--
Python OpenERP Developer http://in.linkedin.com/pub/sandeep-rana/3b/a16/786/
Sandeep
On 5/15/13, 10:46 AM

hey atchuthan

in *sample.py *

datetime field should be like this

 'datetime': fields.datetime('Date with Time'),

not as you defined

and in __openerp.py__ View file should included in the update_xml parameter

that's it

try this and tell me if again

see this one if again

add this action in your view file

 <record id="action_test_form" model="ir.actions.act_window">
 <field name="name">test</field>
 <field name="res_model">test</field>
 <field name="view_type">form</field>
 <field name="view_mode">tree,form</field>
 <field name="view_id" ref="test_tree_view"/>
 </record>

thanks

i tried your suggestion but same error came TypeError: VARCHAR parameter should be an int, got <type 'set'>

Atchuthan
on 5/17/13, 3:58 AM

did you change it 'datetime': fields.datetime('Date wi'h Time'), with above ??

Sandeep
on 5/17/13, 4:52 AM

see my above lines too again i edited my answer

Sandeep
on 5/17/13, 5:00 AM

yeah, i changed according to what you had mentioned. But there is no change. Am getting the same error.

and what does this line provide: <field name="view_id" ref="test_tree_view"/>

Atchuthan
on 5/17/13, 5:30 AM

this is the openerp-server log: TypeError: VARCHAR parameter should be an int, got <type 'set'> 2013-05-17 07:28:01,969 8822 ERROR try openerp.netsvc: VARCHAR parameter should be an int, got <type 'set'>

Atchuthan
on 5/17/13, 5:32 AM
2

Serpent Consulting Services Pvt. Ltd.

--Serpent Consulting Services Pvt. Ltd.--
4341
| 6 6 8
Gandhinagar, India
--Serpent Consulting Services Pvt. Ltd.--

Serpent Consulting Services Pvt. Ltd. Your Odoo/OpenERP Solution, just an email away!

Serpent Consulting Services Pvt. Ltd.
On 5/15/13, 11:11 AM

Hi atchuthan

In openerp.py file put sample_view.xml in update_xml intead of init_xml like this:

"update_xml" : ["sample_view.xml"], init_xml:[],

In sample.py file put datetime field like this :

'datetime': fields.datetime('Date with Time'),

Your xml architecture is wrongly customize because in xml architecture you are use test model and in base dependency there is no test model.

Plz define your xml architecture like this :

   <openerp>
<data>
    <record model="ir.ui.view" id="test_tree_view">
        <field name="name">test.tree</field>
        <field name="model">sample</field>
        <field name="type">tree</field>
        <field name="arch" type="xml">
            <tree string="test">
                <field name="name"/>
                <field name="amount"/>
                <field name="date"/>
            </tree>
        </field>
    </record>

    <record model="ir.ui.view" id="test_form_view">
        <field name="name">test.form</field>
        <field name="model">sample</field>
        <field name="type">form</field>
        <field name="arch" type="xml">
            <form string="test">
                <field name="name"/>
                <field name="amount"/>
                <field name="date"/>
            </form>
        </field>
    </record>

    <record model="ir.actions.act_window" id="action_test_form">
        <field name="name">test</field>
        <field name="res_model">sample</field>
        <field name="view_type">form</field>
        <field name="view_mode">tree,form</field>
    </record>

    <menuitem name="testParent" icon="terp-project" id="testParent_menu"/>

    <menuitem name="NotesChild" parent="testParent_menu" id="NotesChild_menu" />

    <menuitem name="Header" parent="NotesChild_menu" id="Header_menu_mainform" action="action_test_form"/>
</data>

</openerp>

Thank You

I tried your sugestion but no change was noticable.

when trying to install the module, pop-up window came with: TypeError: VARCHAR parameter should be an int, got <type 'set'>

Atchuthan
on 5/17/13, 3:59 AM

About This Community

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

Question tools

1 follower(s)

Stats

Asked: 5/15/13, 10:31 AM
Seen: 2301 times
Last updated: 3/16/15, 8:10 AM