Hello again.

I am having problems to use the "set" method of "Property" or "Function" 
fields. I think my problem has to do with the fact that I don't know the 
names of basic field models, but I am not sure.

I am trying to set the value of a "Property" field (I tried with Function 
also, but thought Property would be easier to start), when I click on a 
button. 

In the "set(ids,model,name,value)" i think my problem is in the "model" 
field. In my button function I don't have an instance of the model (as to 
use *._name), and the names I tried by now didn't work. I suppose that the 
required model is the one that the function/property "emulates" 
(fields.Function("emulatedField",getter,[...])).

Searching the tryton folders I found that 'ir.property' seems to be the 
model name for Property, but that was a special case (most field types are 
not included in "ir"). I think that I had seen "Many2Many" as a model name 
once, and in the test classes I see "Char", "Integer", etc., stated in the 
code, so I can imagine those may be the model names (though they are not 
stated in the field definition, it's just my guess). I have tried many 
combinations and none worked by now.

The code is as follows:

class Contenido(ModelSQL,ModelView):
    'Contenido'
    _name = 'many.contenido'
    _description = __doc__
    name = fields.Char('Nombre')
    numero = fields.Integer(u'Número de identificación')
    mensaje = fields.Property(fields.Char('Mensaje'))

    def botonFun(self,ids):
        objProp = Pool().get('ir.property')
        for elem in self.browse(ids):
            objProp.set(elem.id,'Char','mensaje','hola')

    def __init__(self):
        super(Contenido,self).__init__()
        self._rpc['botonFun']=True

Contenido()


When I click the button I get:

Error:
Traceback (most recent call last):
  File "/dist-packages/trytond/protocols/jsonrpc.py", line 123, in 
_marshaled_dispatch
    response['result'] = dispatch_method(method, params)
  File "/dist-packages/trytond/protocols/jsonrpc.py", line 156, in _dispatch
    res = dispatch(*args)
  File "/dist-packages/trytond/protocols/dispatcher.py", line 156, in 
dispatch
    res = getattr(obj, method)(*args_without_context, **kargs)
  File "/dist-packages/trytond/modules/many/many.py", line 18, in botonFun
    objProp.set(elem.id,'Char','mensaje','hola')
  File "/dist-packages/trytond/ir/property.py", line 133, in set
    ], order=[], limit=1)[0]
  File "/dist-packages/trytond/model/modelsql.py", line 1159, in search
    qu1, qu2, tables, tables_args = self.search_domain(domain)
  File "/dist-packages/trytond/model/modelsql.py", line 1317, in 
search_domain
    qu1, qu2 = self.__search_domain_oper(domain, tables, tables_args)
  File "/dist-packages/trytond/model/modelsql.py", line 1345, in 
__search_domain_oper
    qu1, qu2 = self.__search_domain_calc(tuple_args, tables, tables_args)
  File "/dist-packages/trytond/model/modelsql.py", line 1845, in 
__search_domain_calc
    ].sql_format(arg[2]))
  File "/dist-packages/trytond/backend/fields.py", line 46, in sql_format
    assert isinstance(value, unicode)
AssertionError


Any help will be very appreciated.

Regards,
Miguel Tasende

-- 
[email protected] mailing list

Reply via email to