- _sql_constraints = [
- (
- "date_init_deb_before_date_init_fin",
- "CHECK(date_init_deb<> date_init_fin)",
- "The date_init_deb should be previous date_init_fin",
- ),
- (
- "date_plan_deb_before_date_plan_fin",
- "CHECK(date_plan_deb <> date_plan_fin)",
- "The date_plan_deb should be previous date_plan_fin",
- ),
- (
- "date_reel_deb_before_date_reel_fin",
- "CHECK(date_reel_deb<> date_reel_fin)",
- "The date_reel_deb should be previous date_reel_fin",
- ),
- ]
-
-
-class Chantier(osv.Model):
- _name = "projet.chantier"
-
- _inherit = "projet.qqch"
+ def onchange_main(self, cr, uid, ids, project, domaine, main, context=None):
+ if not main:
+ return {'value': {'main': True},
+ 'warning': {
+ 'title' : "Integrity Warning",
+ 'message' : "One of the domains should be the main domain",
+ }
+ }
+ ids = self.search(
+ cr,
+ uid,
+ [
+ ('project_id', '=', project),
+ ('domaine_id', '!=', domaine),
+ ],
+ context=context,
+ )
+ current_id = self.search(
+ cr,
+ uid,
+ [
+ ('project_id', '=', project),
+ ('domaine_id', '=', domaine),
+ ],
+ context=context,
+ )
+ self.write(cr, uid, ids, {'main': False}, context=context)
+ self.write(cr, uid, current_id, {'main': True}, context=context)
+
+ return {'value': {'main': True}}
+
+
+
+# =============================== PROJET MOE ================================ #
+class ProjetMoe(osv.Model):
+ _name = "cmmi.projet.moe"
+
+ _description = "Rattachement des MOEs au projet."
+
+ def _get_name(self, cr, uid, ids, field_name=None, arg=None, context=None):
+ if isinstance(ids, (int, long)):
+ ids = [ids]
+ return dict([(i, r.moe_id.name) for i, r in
+ zip(ids, self.browse(cr, uid, ids, context=context))])