From c4866fe458ee33cba608b6fffa89d4e1ee613f9e Mon Sep 17 00:00:00 2001 From: =?utf8?q?S=C3=A9bastien=20CHAZALLET?= Date: Sat, 4 May 2013 00:34:48 +0200 Subject: [PATCH] =?utf8?q?Premi=C3=A8res=20exp=C3=A9riences=20wizard?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- __init__.py | 2 + __openerp__.py | 5 +- projet.py | 33 ++++++++++++ views/projet.xml | 7 ++- views/wizards/domaine.xml | 30 +++++++++++ wizards/domaine.py | 124 +++++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 198 insertions(+), 3 deletions(-) create mode 100644 views/wizards/domaine.xml create mode 100644 wizards/__init__.py create mode 100644 wizards/domaine.py diff --git a/__init__.py b/__init__.py index 2341845..01cb177 100644 --- a/__init__.py +++ b/__init__.py @@ -5,3 +5,5 @@ import description import partner import projet import evolution + +import wizards.domaine \ No newline at end of file diff --git a/__openerp__.py b/__openerp__.py index 8fc5f7f..b063cf0 100644 --- a/__openerp__.py +++ b/__openerp__.py @@ -6,11 +6,14 @@ "category": "Tools", "description": """Permet de gérer des projets.""", "data": [ + # Vues associées aux modèles 'views/projet.xml', + # vues associées aux assistants + 'views/wizards/domaine.xml', + # Données 'datas/moe.xml', 'datas/moa.xml', 'datas/domaines.xml', - # fichiers de données (vues, ...) ], "demo": [ 'demo/projet.xml' diff --git a/projet.py b/projet.py index 1e1038d..39b2327 100644 --- a/projet.py +++ b/projet.py @@ -56,6 +56,8 @@ class Projet(osv.Model): string="Structure principale"), } + def action_add_domain(self, cr, uid, ids, context=None): + pass class ProjetDomaine(osv.Model): @@ -80,3 +82,34 @@ class ProjetDomaine(osv.Model): "domaine_id": fields.many2one("cmmi.description.domaine", string="Domaine"), } + + 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}} diff --git a/views/projet.xml b/views/projet.xml index b2d8144..ea74c46 100644 --- a/views/projet.xml +++ b/views/projet.xml @@ -52,10 +52,13 @@ +