Hi all,
I'm extending the partner model. Just something dummy for test openERP concept 
before going into real developments. I create my class like thise
from osv import osv, fields
import netsvc


class pocscs(osv.osv):


   _name = 'res.partner'
   _inherit = 'res.partner'
   _columns = {
        'age': fields.integer('Age'),
        'typeage': fields.char('Type age', 
size=128),
   }
   _defaults = {
   }
   def age_change(self, cr, uid, ids, age, id):
      logger.notifyChannel('pocscs', netsvc.LOG_ERROR, 
"Setting typeage!!!!!!")
&nbsp; &nbsp;&nbsp; &nbsp;if age < 20&#58;
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;self.write&#40;cr, uid, ids, 
&#123;'typeage'&#58;'Personne jeune'&#125;&#41;
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;logger.notifyChannel&#40;'pocscs', 
netsvc.LOG_ERROR, "Age is &#58;&nbsp; '%s' and Type age is '%s'!" % &#40;age, 
res.partner&#91;id&#93;.typeage&#41;&#41;
&nbsp; &nbsp;&nbsp; &nbsp;elif 20 < age < 50&#58;
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;self.write&#40;cr, uid, ids, 
&#123;'typeage'&#58;'Personne mature'&#125;&#41;
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;logger.notifyChannel&#40;'pocscs', 
netsvc.LOG_ERROR, "Age is &#58;&nbsp; '%s' and Type age is '%s'!" % &#40;age, 
res.partner&#91;id&#93;.typeage&#41;&#41;
&nbsp; &nbsp;&nbsp; &nbsp;else&#58;
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;self.write&#40;cr, uid, ids, 
&#123;'typeage'&#58;'Personne du troisieme age'&#125;&#41;
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;logger.notifyChannel&#40;'pocscs', 
netsvc.LOG_ERROR, "Age is &#58;&nbsp; '%s' and Type age is '%s'!" % &#40;age, 
res.partner&#91;id&#93;.typeage&#41;&#41;
&nbsp; &nbsp;&nbsp; &nbsp;return res
pocscs&#40;&#41;


and here the view I do some stuffs with in :
name="age" on_change="age_change&#40;age, id&#41;

Everything work fine, I install my module, and in the web client I can see 
Partner form with my two fields but when I change the "age" value I get a alert 
with 
> 'res.partner' object has no attribute 'age_change'

And for sure as we can see I've defined a age_change method.
Have I to define this method in res.partner (which will not be a best practice).
I'm I doing somethin wrong?
Thanks,
Mouhamed




-------------------- m2f --------------------

--
http://www.openerp.com/forum/viewtopic.php?p=27628#27628

-------------------- m2f --------------------


_______________________________________________
Tinyerp-users mailing list
http://tiny.be/mailman/listinfo/tinyerp-users

Reply via email to