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

fields.function storing problem

By
Xiangyu
on 6/14/13, 9:45 PM 1,985 views

Hi all,

Here is my idea,

i would like to store a value of " if a sale.order.line is taxed or not" in char.

before, i used store = false since i didnt need the value, but now i would like to store the value.

it worked before when store=false


def _is_taxed(self, cr, uid, ids, field_name, arg, context=None):
        val = {}
        for record in self.browse(cr, uid, ids):
            if record.tax_id:
                val[record.id] = 'T'
            else:
                val[record.id] = 'N/T'
        return val

'tax_mark': fields.function(_is_taxed, type='char', size='64', string=" 'T' for taxed, and 'N/T' for non taxable", store=False, method=True,),

but when i change store = True; or store = { 'sale.order.line':(some_function_name,['tax_id', 'product_id'], 10) }),

this error pops up when i upgrade the module

OpenERP Server Error Client Traceback (most recent call last): File "/opt/openerp/server/openerp/addons/web/common/http.py", line 180, in dispatch response["result"] = method(controller, self, *self.params) File "/opt/openerp/server/openerp/addons/web/controllers/main.py", line 1052, in call_button action = self.call_common(req, model, method, args, domain_id, context_id) File "/opt/openerp/server/openerp/addons/web/controllers/main.py", line 996, in call_common return self._call_kw(req, model, method, args, {}) File "/opt/openerp/server/openerp/addons/web/controllers/main.py", line 1010, in _call_kw return getattr(req.session.model(model), method)(args, **kwargs) File "/opt/openerp/server/openerp/addons/web/common/openerplib/main.py", line 250, in proxy args, kw) File "/opt/openerp/server/openerp/addons/web/common/openerplib/main.py", line 117, in proxy result = self.connector.send(self.service_name, method, *args) File "/opt/openerp/server/openerp/addons/web/common/http.py", line 608, in send raise xmlrpclib.Fault(openerp.tools.exception_to_unicode(e), formatted_info)

Server Traceback (most recent call last): File "/opt/openerp/server/openerp/addons/web/common/http.py", line 593, in send return openerp.netsvc.dispatch_rpc(service_name, method, args) File "/opt/openerp/server/openerp/netsvc.py", line 360, in dispatch_rpc result = ExportService.getService(service_name).dispatch(method, params) File "/opt/openerp/server/openerp/service/web_services.py", line 586, in dispatch res = fn(db, uid, params) File "/opt/openerp/server/openerp/osv/osv.py", line 186, in execute_kw return self.execute(db, uid, obj, method, *args, *kw or {}) File "/opt/openerp/server/openerp/osv/osv.py", line 129, in wrapper return f(self, dbname, args, *kwargs) File "/opt/openerp/server/openerp/osv/osv.py", line 195, in execute res = self.execute_cr(cr, uid, obj, method, args, *kw) File "/opt/openerp/server/openerp/osv/osv.py", line 183, in execute_cr return getattr(object, method)(cr, uid, args, *kw) File "/opt/openerp/server/openerp/addons/base/module/wizard/base_module_upgrade.py", line 101, in upgrade_module _db, pool = pooler.restart_pool(cr.dbname, update_module=True) File "/opt/openerp/server/openerp/pooler.py", line 39, in restart_pool registry = RegistryManager.new(db_name, force_demo, status, update_module, True) File "/opt/openerp/server/openerp/modules/registry.py", line 202, in new openerp.modules.load_modules(registry.db, force_demo, status, update_module) File "/opt/openerp/server/openerp/modules/loading.py", line 334, in load_modules processed = load_marked_modules(cr, graph, states_to_load, force, status, report, loaded_modules) File "/opt/openerp/server/openerp/modules/loading.py", line 253, in load_marked_modules loaded, processed = load_module_graph(cr, graph, progressdict, report=report, skip_modules=loaded_modules) File "/opt/openerp/server/openerp/modules/loading.py", line 170, in load_module_graph init_module_models(cr, package.name, models) File "/opt/openerp/server/openerp/modules/module.py", line 378, in init_module_models result = obj._auto_init(cr, {'module': module_name}) File "/opt/openerp/server/openerp/osv/orm.py", line 2997, in _auto_init cr.execute('ALTER TABLE "%s" ADD COLUMN "%s" %s' % (self._table, k, get_pg_type(f)[1])) File "/opt/openerp/server/openerp/osv/orm.py", line 585, in get_pg_type pg_type = get_pg_type(f, getattr(fields, f._type)) File "/opt/openerp/server/openerp/osv/orm.py", line 574, in get_pg_type pg_type = ('varchar', pg_varchar(f.size)) File "/opt/openerp/server/openerp/osv/orm.py", line 539, in pg_varchar % type(size)) TypeError: VARCHAR parameter should be an int, got <type 'str'="">

Thanks for the help

1

Ray Carnes

--Ray Carnes--
15677
| 9 7 9
Greater Los Angeles, United States
--Ray Carnes--

Senior Odoo Analyst

OpenERP 6.1, 7.0 and Odoo 8.0, 9.0 (Since 2012)

Completed Functional and Technical Training.

Major Skills:

  • Needs Discovery and Requirements Analysis;

  • Function and Technical Specifications;

  • Project Planning;

  • Prototyping and Proof of concepts;

  • Data migration;

  • Configuration & Customization (UI and modules);

  • Integration - data, business logic and service levels;

  • Training and Knowledge transfer;

  • Go Live support;

  • Help desk;

  • Version Migration.

I have over 20 years of experience empowering and enabling users with enterprise information systems that make a real and measurable difference in their ability to proactively manage their businesses and organizations. 

Ray Carnes
On 6/15/13, 12:06 AM

The error message TypeError: VARCHAR parameter should be an int, got <type 'str'=""> is giving you a clue:

size='64'

should be

size=64

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: 6/14/13, 9:45 PM
Seen: 1985 times
Last updated: 3/16/15, 8:10 AM