Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- portrait = fields.Integer(
- string=u'Commune',
- help=u'Commune',
- )
- protection = fields.Many2Many(
- 'portrait.page71-protection.area',
- 'page71',
- 'protection',
- string=u'Protection',
- help=u'Statuts de protection',
- on_change_with=['portrait']
- )
- def on_change_with_protection(self):
- if self.portrait is not None:
- Protections = Pool().get('protection.area')
- cursor = Transaction().cursor
- prot=[]
- cursor.execute('SELECT a.id '
- 'FROM portrait_commune c, portrait_portrait p, protection_area a '
- 'WHERE c.id = p.commune AND st_dwithin(c.geom, a.geom,0) AND p.id = %s ', (str(self.portrait.id),))
- for protid in cursor.fetchall():
- prots = Protections.browse(protid)[0]
- try:
- prot.append(prots)
- except Exception, e:
- raise
- return prot
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement