Obrigado Paulino!!!

But, how can I be sure that the different output will only ocurr inside my 
module?  I gather that has something to do with context so I tried the 
following:

<field name="context">&#123;'contact_display'&#58; 'sort_form'&#125;</field>

(in my view)


def name_get&#40;self, cr, user, ids, context=&#123;&#125;&#41;&#58;
&nbsp; &nbsp; &nbsp; &nbsp; if not len&#40;ids&#41;&#58;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return &#91;&#93;
&nbsp; &nbsp; &nbsp; &nbsp; res = &#91;&#93;
&nbsp; &nbsp; &nbsp; &nbsp; for r in self.read&#40;cr, user, ids, 
&#91;'designacao','name','zip','city','partner_id', 'street'&#93;&#41;&#58;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if context.get&#40;'contact_display', 
'contact'&#41;=='partner'&#58;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 
res.append&#40;&#40;r&#91;'id'&#93;, 
r&#91;'partner_id'&#93;&#91;1&#93;&#41;&#41;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else&#58; 
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if 
context.get&#40;'contact_display', 'contact'&#41;=='sort_form'&#58;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; addr = 
r&#91;'designacao'&#93; or r&#91;'name'&#93; or ''
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else&#58;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; addr = 
r&#91;'name'&#93; or ''
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if 
r&#91;'name'&#93; and &#40;r&#91;'zip'&#93; or r&#91;'city'&#93;&#41;&#58;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 
&nbsp; addr += ', '
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; addr += 
&#40;r&#91;'street'&#93; or ''&#41; + ' ' + &#40;r&#91;'zip'&#93; or ''&#41; + 
' ' + &#40;r&#91;'city'&#93; or ''&#41;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 
res.append&#40;&#40;r&#91;'id'&#93;, addr.strip&#40;&#41; or '/'&#41;&#41;
&nbsp; &nbsp; &nbsp; &nbsp; return res

(in my module's .py)

So, what I'm trying to do is to run a line of code only when my module calls 
the method. However, it doesn't work.

Truth is I didn't find any documentation explaining the "context" thing, so, 
I'm doing this using common sense...




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

--
http://www.openobject.com/forum/viewtopic.php?p=36402#36402

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


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

Reply via email to