Advertisement
Guest User

Untitled

a guest
Nov 27th, 2014
194
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.20 KB | None | 0 0
  1. portrait = fields.Integer(
  2. string=u'Commune',
  3. help=u'Commune',
  4. )
  5.  
  6. protection = fields.Many2Many(
  7. 'portrait.page71-protection.area',
  8. 'page71',
  9. 'protection',
  10. string=u'Protection',
  11. help=u'Statuts de protection',
  12. on_change_with=['portrait']
  13. )
  14.  
  15. def on_change_with_protection(self):
  16. if self.portrait is not None:
  17. Protections = Pool().get('protection.area')
  18. cursor = Transaction().cursor
  19. prot=[]
  20. cursor.execute('SELECT a.id '
  21. 'FROM portrait_commune c, portrait_portrait p, protection_area a '
  22. 'WHERE c.id = p.commune AND st_dwithin(c.geom, a.geom,0) AND p.id = %s ', (str(self.portrait.id),))
  23. for protid in cursor.fetchall():
  24. prots = Protections.browse(protid)[0]
  25. try:
  26. prot.append(prots)
  27. except Exception, e:
  28. raise
  29. return prot
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement