Thank you! I could have been a lot of time searching for it. But still 
doesn't work to me.

I added to the Algo class:     _rpc = {'apreto':True}
to the code, but still the same message. I tried other ways of saying 
"True" but none works (putting it under a string, using 1, "1",True,"True" 
not working).
What am I doing wrong? (I have the intuition that it may be something very 
stupid and I'll be ashamed to have asked but still can't find it. If you 
have any piece of working code that I could see it would be great.)


The final code is:

class Algo(ModelSQL,ModelView):
    'Algo'
    _name = 'hello.algo'
    _description = __doc__
    _rpc = {'apreto':True}

    name = fields.Char('Nombre')
    holas = fields.Many2Many('hello.relacion','algo','hola','Holas')
    cosa=fields.Char('Cosa')

    def apreto(self,ids):
        for elem in self.browse(ids):
            elem.cosa="lelele"


Algo()

El viernes, 5 de octubre de 2012 16:08:48 UTC-3, Miguel Tasende escribió:
>
> Hi!
>
> This is probably another easy one, but I couldn't find a module that uses 
> buttons (and I want to), so I can't see sources for this one (I watched 
> Party,Company, and gnu_health modules and no one uses buttons it seems).
>
> The problem is that I can't call an internal class function. The button 
> shows in the GUI but when I hit it it says:
>
> "calling method apreto in hello.algo is not allowed"
>
> I thought it could be a matter of permissions or scope, but can't find the 
> answer. Any suggestion is greatly appreciated. Thanks in advance!
>
>
> The code (not the entire file cos it's long) would be:
>
> from trytond.model import ModelView, ModelSQL, fields
> from trytond.pool import Pool
> from trytond.res import User
> from trytond.pyson import Eval, If
>
> class Algo(ModelSQL,ModelView):
>     'Algo'
>     _name = 'hello.algo'
>     _description = __doc__
>     name = fields.Char('Nombre')
>     holas = fields.Many2Many('hello.relacion','algo','hola','Holas')
>     cosa=fields.Char('Cosa')
>
>     def apreto(self,ids):
>         for elem in self.browse(ids):
>             elem.cosa="lelele"
>
> Algo()
>
>
> The xml for the form view is just (I suppose only de "button" tag is 
> important here):
>
> <record model="ir.ui.view" id="algo_view_form">
>     <field name="model">hello.algo</field>
>     <field name="type">form</field>
>     <field name="arch" type="xml">
>         <![CDATA[
>         <form string="Algo Formularialmente...">
>             <label name="name"/>
>             <field name="name" xfill="1"/>
>             <label name="holas"/>
>             <field name="holas"/>
>             <label name="cosa"/>
>             <field name="cosa"/>
>             <button string="Apretar acá" name="apreto"/>
>         </form>
>         ]]>
>     </field>
> </record>
>

-- 
tryton-dev@googlegroups.com mailing list

Reply via email to