← Back to team overview

openerp-dev-web team mailing list archive

lp:~openerp-dev/openobject-addons/training_osv_memory_wizard_gpa1 into lp:~openobject-training/openobject-addons/training_with_history

 

gpa(Open ERP) has proposed merging lp:~openerp-dev/openobject-addons/training_osv_memory_wizard_gpa1 into lp:~openobject-training/openobject-addons/training_with_history.

Requested reviews:
  Bhumika (OpenERP) (sbh-openerp)

For more details, see:
https://code.launchpad.net/~openerp-dev/openobject-addons/training_osv_memory_wizard_gpa1/+merge/53787

trainging module wizard converted to osv_memory
-- 
https://code.launchpad.net/~openerp-dev/openobject-addons/training_osv_memory_wizard_gpa1/+merge/53787
Your team OpenERP R&D Team is subscribed to branch lp:~openerp-dev/openobject-addons/training_osv_memory_wizard_gpa1.
=== modified file 'training/__openerp__.py'
--- training/__openerp__.py	2011-03-14 10:48:46 +0000
+++ training/__openerp__.py	2011-03-17 11:17:58 +0000
@@ -77,7 +77,12 @@
         'security/training_security.xml',
         'security/roles.xml',
         'security/ir.model.access.csv',
-
+        'wizard/training_subscription_session.xml',
+        'wizard/validate_course_view.xml',
+        'wizard/training_subscription_line_confirm.xml',
+        'wizard/training_create_offer.xml',
+        'wizard/training_create_blockl_offer.xml',
+        'wizard/training_subscription_second_line.xml',
         # TODO move this into the base_contact module
         'contact_security/groups.xml',
         'contact_security/ir.model.access.csv',

=== modified file 'training/training.py'
--- training/training.py	2011-03-14 10:48:46 +0000
+++ training/training.py	2011-03-17 11:17:58 +0000
@@ -518,8 +518,8 @@
 
         'purchase_line_ids' : fields.one2many('training.course.purchase_line', 'course_id',
                                               'Supplier Commands',
-                                              help="The purchase line helps to create a purchase order for the seance",
-                                              read=['training.group_course_manager'], write=['training.group_course_manager']),
+                                              help="The purchase line helps to create a purchase order for the seance",),
+                                              #read=['training.group_course_manager'], write=['training.group_course_manager']),
 
 
         'has_support' : fields.function(_has_support,
@@ -638,6 +638,7 @@
                                                    limit=limit, order=order, context=context, count=count)
 
     def action_workflow_validate(self, cr, uid, ids, context=None):
+        print "action_workflow_validate:::::::::: 641:::::::::"
         return self.write(cr, uid, ids, {'state_course' : 'validated'}, context=context)
 
     def reset_to_draft(self, cr, uid, ids, context=None):
@@ -3254,7 +3255,7 @@
         res = dict.fromkeys(ids, 0)
 
         for obj in self.browse(cr, uid, ids, context=context):
-            res[obj.id] = obj.session_id.available_seats - obj.session_id.draft_subscriptions
+            res[obj.id] = int(obj.session_id.available_seats) - int(obj.session_id.draft_subscriptions)
 
         return res
 

=== modified file 'training/training_wizard.xml'
--- training/training_wizard.xml	2011-02-23 08:37:51 +0000
+++ training/training_wizard.xml	2011-03-17 11:17:58 +0000
@@ -1,56 +1,56 @@
 <?xml version="1.0" encoding="UTF-8" ?>
 <openerp>
     <data>
-        <wizard
+        <!--wizard
             id="wizard_training_subscription_line_confirm"
             keyword="client_action_multi"
             model="training.subscription.line"
             name="training.subscription.line.confirm"
             multi="True"
             groups="training.group_subscription_manager"
-            string="Confirm Subscription Lines"/>
+            string="Confirm Subscription Lines"/-->
 
-       <wizard
+       <!--wizard
            id="wizard_training_subscription_line_second"
            keyword="client_action_multi"
            multi="True"
            model="training.subscription.line.second"
            name="training.subscription.line_second"
            groups="training.group_subscription_manager"
-           string="Subscription Second Line"/>
+           string="Subscription Second Line"/-->
 
-        <wizard
+        <!--wizard
             id="wizard_training_course_validate"
             name="training.course.validate"
             keyword="client_action_multi"
             model="training.course"
             groups="training.group_course_manager"
-            string="Validate Course(s)" />
+            string="Validate Course(s)" /-->
 
-        <wizard
+        <!--wizard
             id="wizard_training_course_create_offer"
             name="training.course.create.offer"
             keyword="client_action_multi"
             model="training.course"
             groups="training.group_course_manager"
-            string="Create Standalone Offer(s)" />
+            string="Create Standalone Offer(s)" /-->
 
-        <wizard
+        <!--wizard
             id="wizard_training_course_create_block_offer"
             name="training.course.create.block.offer"
             keyword="client_action_multi"
             model="training.course"
             multi="True"
             groups="training.group_course_manager"
-            string="Create Block Offer" />
+            string="Create Block Offer" /-->
 
-        <wizard
+        <!--wizard
             id="wizard_subscription_session"
             keyword="client_action_multi"
             model="training.session"
             name="training.subscription.session"
             groups="training.group_subscription_manager"
-            string="Create Subscription"/>
+            string="Create Subscription"/-->
 
     </data>
 </openerp>

=== modified file 'training/wizard/__init__.py'
--- training/wizard/__init__.py	2009-10-30 12:07:12 +0000
+++ training/wizard/__init__.py	2011-03-17 11:17:58 +0000
@@ -20,16 +20,12 @@
 #
 ##############################################################################
 
-import wizard_not_implemented
-import wizard_subscription_line_invoice
-import wizard_subscription_line_confirm
-import wizard_subscription_line_change_participant
 import wizard_create_session
-import wizard_subscription_second_line
-import wizard_create_offer
-import wizard_create_block_offer
-import wizard_validate_course
-import wizard_spam
-import wizard_subscription_session
+import training_subscription_session
+import validate_course
+import training_subscription_line_confirm
+import training_create_offer
+import training_create_block_offer
+import training_subscription_second_line
 
 # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

=== added file 'training/wizard/training_create_block_offer.py'
--- training/wizard/training_create_block_offer.py	1970-01-01 00:00:00 +0000
+++ training/wizard/training_create_block_offer.py	2011-03-17 11:17:58 +0000
@@ -0,0 +1,105 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+#    OpenERP, Open Source Management Solution
+#    Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
+#
+#    This program is free software: you can redistribute it and/or modify
+#    it under the terms of the GNU Affero General Public License as
+#    published by the Free Software Foundation, either version 3 of the
+#    License, or (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU Affero General Public License for more details.
+#
+#    You should have received a copy of the GNU Affero General Public License
+#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
+#
+##############################################################################
+
+from osv import osv, fields
+from tools.translate import _
+import netsvc
+
+class training_create_block_offer(osv.osv_memory):
+    _name = 'training.create.block.offer'
+    _columns = {
+        'name' : fields.char('Name', size=64, required=True),
+        'type_id' : fields.many2one('training.course_type', 'Type', required=True,),
+        'lang_id' : fields.many2one('res.lang', 'Language', required=True,),
+        'product_line_id' : fields.many2one('training.course_category', 'Product Line', select=1, required=True),
+    }
+
+    def default_get(self, cr, uid, fields, context=None):
+        if context is None:
+            context = {}
+        proxy = self.pool.get(context['active_model'])
+        name = None
+        product_line = False
+        languages = set()
+        for course in proxy.browse(cr, uid, context.get('active_ids', []), context=context):
+            if course.state_course != 'validated':
+                raise osv.except_osv(_('Warning'), _("Please, The state of all courses must be 'validated'"))
+            if name is None:
+                name = course.name
+            product_line = course.category_id.id
+            languages.add(course.lang_id.id)
+
+        if len(languages) > 1:
+            raise osv.except_osv(_('Warning'), _('You have selected a course with a different language'))
+
+        return {'name':name, 'lang_id':list(languages)[0], 'product_line_id':product_line, 'type_id':course.course_type_id.id}
+
+
+    def create_offers(self, cr, uid, ids, context=None):
+        if context is None:
+            context = {}
+
+        form = self.read(cr, uid, ids, [])[0]
+        workflow = netsvc.LocalService('workflow')
+        proxy = self.pool.get('training.offer')
+        offer_ids = []
+        for course in self.pool.get('training.course').browse(cr, uid, context.get('active_ids',[]), context):
+            if course.state_course == 'validated':
+                offer_id = proxy.create(cr, uid,
+                                        {
+                                        'name' : form['name'],
+                                        'lang_id' : form['lang_id'],
+                                        'type_id' : form['type_id'],
+                                        'product_line_id': form['product_line_id']
+                                        },
+                                        context=context)
+
+                self.pool.get('training.course.offer.rel').create(cr, uid, {'offer_id' : offer_id, 'course_id' : course.id}, context=context)
+                #workflow.trg_validate(uid, 'training.offer', offer_id, 'signal_validate', cr)
+                offer_ids.append(offer_id)
+
+        number_of_offers = len(offer_ids)
+        if not number_of_offers:
+            return {}
+        elif number_of_offers == 1:
+            return {
+                'res_id' : int(offer_ids[0]),
+                'name' : 'Offers',
+                'view_type' : 'form',
+                'view_mode' : 'form,tree',
+                'res_model' : 'training.offer',
+                'view_id' : False,
+                'type' : 'ir.actions.act_window',
+            }
+        else:
+            return {
+                'domain' : "[('id', 'in', [%s])]" % ','.join(map(str,offer_ids)),
+                'name' : 'Offers',
+                'view_type' : 'form',
+                'view_mode' : 'tree,form',
+                'res_model' : 'training.offer',
+                'view_id' : False,
+                'type' : 'ir.actions.act_window',
+            }
+
+training_create_block_offer()
+
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
\ No newline at end of file

=== added file 'training/wizard/training_create_blockl_offer.xml'
--- training/wizard/training_create_blockl_offer.xml	1970-01-01 00:00:00 +0000
+++ training/wizard/training_create_blockl_offer.xml	2011-03-17 11:17:58 +0000
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<openerp>
+	<data>
+	    <record model="ir.ui.view" id="training_create_block_offer_form">
+	        <field name="name">training.create.block.offer.form</field>
+	        <field name="model">training.create.block.offer</field>
+	        <field name="type">form</field>
+	        <field name="arch" type="xml">
+	            <form string="Offer Description">
+	            	<group colspan="2" col="2">
+						<field name="name" />
+						<field name="type_id" />
+						<field name="lang_id" />
+						<field name="product_line_id" />
+					</group>
+	            	<newline/>
+	                <group colspan="2" col="2">
+	                    <button type="special" special="cancel" string="Cancel" icon="gtk-cancel"/>
+	                    <button type="object" name="create_offers" string="Create Offers" icon="gtk-apply"/>
+	                </group>
+	            </form>
+	        </field>
+	    </record>
+
+	    <act_window name="Create Block Offer"
+			    res_model="training.create.block.offer"
+			    src_model="training.course"
+			    view_mode="form"
+			    target="new"
+	            key2="client_action_multi"
+			    id="action_training_create_block_offer"/>
+	</data>
+</openerp>

=== added file 'training/wizard/training_create_offer.py'
--- training/wizard/training_create_offer.py	1970-01-01 00:00:00 +0000
+++ training/wizard/training_create_offer.py	2011-03-17 11:17:58 +0000
@@ -0,0 +1,86 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+#    OpenERP, Open Source Management Solution
+#    Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
+#
+#    This program is free software: you can redistribute it and/or modify
+#    it under the terms of the GNU Affero General Public License as
+#    published by the Free Software Foundation, either version 3 of the
+#    License, or (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU Affero General Public License for more details.
+#
+#    You should have received a copy of the GNU Affero General Public License
+#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
+#
+##############################################################################
+
+from osv import osv, fields
+from tools.translate import _
+import netsvc
+
+class training_create_offer(osv.osv_memory):
+    _name = 'training.create.offer'
+
+    def default_get(self, cr, uid, fields, context=None):
+        if context is None:
+            context = {}
+        if context.get('active_id',False):
+            course = self.pool.get('training.course').browse(cr, uid, context['active_id'], context=context)
+            if course.state_course != 'validated':
+                raise osv.except_osv(_('Warning'),_("Please, you can create an offer with a validated course"))
+        return {}
+
+    def create_offers(self, cr, uid, ids, context=None):
+        if context is None:
+            context = {}
+
+        workflow = netsvc.LocalService('workflow')
+        proxy = self.pool.get('training.offer')
+        offer_ids = []
+        for course in self.pool.get('training.course').browse(cr, uid, context.get('active_ids',[]), context):
+            if course.state_course == 'validated':
+                offer_id = proxy.create(cr, uid,
+                                        {
+                                        'name' : course.name,
+                                        'lang_id' : course.lang_id.id,
+                                        'type_id' : course.course_type_id.id,
+                                        'product_line_id': course.category_id.id
+                                        },
+                                        context=context)
+
+                self.pool.get('training.course.offer.rel').create(cr, uid, {'offer_id' : offer_id, 'course_id' : course.id}, context=context)
+                #workflow.trg_validate(uid, 'training.offer', offer_id, 'signal_validate', cr)
+                offer_ids.append(offer_id)
+
+        number_of_offers = len(offer_ids)
+        if not number_of_offers:
+            return {}
+        elif number_of_offers == 1:
+            return {
+                'res_id' : int(offer_ids[0]),
+                'name' : 'Offers',
+                'view_type' : 'form',
+                'view_mode' : 'form,tree',
+                'res_model' : 'training.offer',
+                'view_id' : False,
+                'type' : 'ir.actions.act_window',
+            }
+        else:
+            return {
+                'domain' : "[('id', 'in', [%s])]" % ','.join(map(str,offer_ids)),
+                'name' : 'Offers',
+                'view_type' : 'form',
+                'view_mode' : 'tree,form',
+                'res_model' : 'training.offer',
+                'view_id' : False,
+                'type' : 'ir.actions.act_window',
+            }
+
+training_create_offer()
+
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
\ No newline at end of file

=== added file 'training/wizard/training_create_offer.xml'
--- training/wizard/training_create_offer.xml	1970-01-01 00:00:00 +0000
+++ training/wizard/training_create_offer.xml	2011-03-17 11:17:58 +0000
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<openerp>
+	<data>
+	    <record model="ir.ui.view" id="training_create_offer_form">
+	        <field name="name">training.create.offer.form</field>
+	        <field name="model">training.create.offer</field>
+	        <field name="type">form</field>
+	        <field name="arch" type="xml">
+	            <form string="Create Offers">
+	            	<label string="Do you want to create an offer for each selected course ?" />
+	            	<newline/>
+	                <group colspan="2" col="2">
+	                    <button type="special" special="cancel" string="Cancel" icon="gtk-cancel"/>
+	                    <button type="object" name="create_offers" string="Create Offers" icon="gtk-apply"/>
+	                </group>
+	            </form>
+	        </field>
+	    </record>
+
+	    <act_window name="Create Standalone Offer"
+			    res_model="training.create.offer"
+			    src_model="training.course"
+			    view_mode="form"
+			    target="new"
+	            key2="client_action_multi"
+			    id="action_training_create_offer"/>
+	</data>
+</openerp>

=== added file 'training/wizard/training_subscription_line_confirm.py'
--- training/wizard/training_subscription_line_confirm.py	1970-01-01 00:00:00 +0000
+++ training/wizard/training_subscription_line_confirm.py	2011-03-17 11:17:58 +0000
@@ -0,0 +1,39 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+#    OpenERP, Open Source Management Solution
+#    Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
+#
+#    This program is free software: you can redistribute it and/or modify
+#    it under the terms of the GNU Affero General Public License as
+#    published by the Free Software Foundation, either version 3 of the
+#    License, or (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU Affero General Public License for more details.
+#
+#    You should have received a copy of the GNU Affero General Public License
+#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
+#
+##############################################################################
+
+from osv import osv, fields
+from tools.translate import _
+import netsvc
+
+class training_subscription_line_confim(osv.osv_memory):
+    _name = 'training.subscription.line.confim'
+
+    def confirm_line(self, cr, uid, ids, context=None):
+        if context is None:
+            context= {}
+        wf_service = netsvc.LocalService("workflow")
+        for obj_id in context.get('active_ids', []):
+            wf_service.trg_validate(uid, 'training.subscription.line', obj_id, 'signal_confirm', cr)
+        return {}
+
+training_subscription_line_confim()
+
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
\ No newline at end of file

=== added file 'training/wizard/training_subscription_line_confirm.xml'
--- training/wizard/training_subscription_line_confirm.xml	1970-01-01 00:00:00 +0000
+++ training/wizard/training_subscription_line_confirm.xml	2011-03-17 11:17:58 +0000
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<openerp>
+	<data>
+	    <record model="ir.ui.view" id="training_subscription_line_confim_form">
+	        <field name="name">training.subscription.line.confim.form</field>
+	        <field name="model">training.subscription.line.confim</field>
+	        <field name="type">form</field>
+	        <field name="arch" type="xml">
+	            <form string="Confirm Subscription Lines">
+	            	<label string="Do you want to confirm all subscription lines ?" />
+	            	<newline/>
+	                <group colspan="2" col="2">
+	                    <button type="special" special="cancel" string="Cancel" icon="gtk-cancel"/>
+	                    <button type="object" name="confirm_line" string="Confirm" icon="gtk-apply"/>
+	                </group>
+	            </form>
+	        </field>
+	    </record>
+
+	    <act_window name="Confirm Subscription Lines"
+			    res_model="training.subscription.line.confim"
+			    src_model="training.subscription.line"
+			    view_mode="form"
+			    target="new"
+	            key2="client_action_multi"
+			    id="action_training_subscription_line_confim"/>
+	</data>
+</openerp>

=== added file 'training/wizard/training_subscription_second_line.py'
--- training/wizard/training_subscription_second_line.py	1970-01-01 00:00:00 +0000
+++ training/wizard/training_subscription_second_line.py	2011-03-17 11:17:58 +0000
@@ -0,0 +1,70 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+#    OpenERP, Open Source Management Solution
+#    Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
+#
+#    This program is free software: you can redistribute it and/or modify
+#    it under the terms of the GNU Affero General Public License as
+#    published by the Free Software Foundation, either version 3 of the
+#    License, or (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU Affero General Public License for more details.
+#
+#    You should have received a copy of the GNU Affero General Public License
+#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
+#
+##############################################################################
+
+from osv import osv, fields
+from tools.translate import _
+
+class training_subscription_second_line(osv.osv_memory):
+    _name = 'training.subscription.second.line'
+
+    def make_subscription(self, cr, uid, ids, context=None):
+        if context is None:
+            context={}
+
+        subscription_line_second_ids = context['active_ids']
+
+        if not subscription_line_second_ids:
+            return {}
+
+        sls_proxy = self.pool.get('training.subscription.line.second')
+        subscription_proxy= self.pool.get('training.subscription')
+        subscription_line_proxy = self.pool.get('training.subscription.line')
+
+        partners = {}
+
+        for sls in sls_proxy.browse(cr, uid, subscription_line_second_ids, context=context):
+            if sls.partner_id:
+                partners.setdefault(sls.partner_id.id, []).append(sls)
+
+        for partner_id, lines in partners.iteritems():
+            values = subscription_proxy.on_change_partner(cr, uid, [], partner_id)['value']
+            values.update({
+                'partner_id' : partner_id,
+            })
+            subscription_id = subscription_proxy.create(cr, uid, values, context=context)
+
+            for line in lines:
+                subscription_line_proxy.create(cr, uid, {'subscription_id' : subscription_id,
+                                                         'session_id' : line.session_id.id,
+                                                         'contact_id' : line.job_id.id,
+                                                         'price': 1.0,
+                                                         'job_id':line.job_id.id,
+                                                         'price_list_id':line.job_id.pricelist_id.id,
+                                                         'state': 'draft',
+                                                        },
+                                               context=context)
+                line.unlink()
+
+        return {}
+
+training_subscription_second_line()
+
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
\ No newline at end of file

=== added file 'training/wizard/training_subscription_second_line.xml'
--- training/wizard/training_subscription_second_line.xml	1970-01-01 00:00:00 +0000
+++ training/wizard/training_subscription_second_line.xml	2011-03-17 11:17:58 +0000
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<openerp>
+	<data>
+	    <record model="ir.ui.view" id="training_subscription_second_line_form">
+	        <field name="name">training.subscription.second.line.form</field>
+	        <field name="model">training.subscription.second.line</field>
+	        <field name="type">form</field>
+	        <field name="arch" type="xml">
+	            <form string="Mass Subscription Second Line">
+	            	<label string="This wizard will generate the subscription !" />
+	            	<newline/>
+	                <group colspan="2" col="2">
+	                    <button type="special" special="cancel" string="Cancel" icon="gtk-cancel"/>
+	                    <button type="object" name="make_subscription" string="Make Subscription" icon="gtk-apply"/>
+	                </group>
+	            </form>
+	        </field>
+	    </record>
+
+	    <act_window name="Subscription Second Line"
+			    res_model="training.subscription.second.line"
+			    src_model="training.subscription.line.second"
+			    view_mode="form"
+			    target="new"
+	            key2="client_action_multi"
+			    id="action_training_subscription_line_second"/>
+	</data>
+</openerp>

=== added file 'training/wizard/training_subscription_session.py'
--- training/wizard/training_subscription_session.py	1970-01-01 00:00:00 +0000
+++ training/wizard/training_subscription_session.py	2011-03-17 11:17:58 +0000
@@ -0,0 +1,71 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+#    OpenERP, Open Source Management Solution
+#    Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
+#
+#    This program is free software: you can redistribute it and/or modify
+#    it under the terms of the GNU Affero General Public License as
+#    published by the Free Software Foundation, either version 3 of the
+#    License, or (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU Affero General Public License for more details.
+#
+#    You should have received a copy of the GNU Affero General Public License
+#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
+#
+##############################################################################
+
+from osv import osv, fields
+from tools.translate import _
+
+class training_subscription_session(osv.osv_memory):
+    _name = 'training.subscription.session'
+    _columns = {
+        'partner_id': fields.many2one('res.partner', 'Partner',  required=True),
+        'job_ids': fields.many2many('res.partner.job', 'res_partner_job_rel', 'training_id', 'partner_id', 'Contacts'),
+        'line_ids': fields.many2many('training.session', 'training_session_rel', 'training_id', 'session_id', 'Sessions'),
+    }
+
+    def make_subscription(self, cr, uid, ids, context=None):
+        if context is None:
+            context = {}
+        form = self.read(cr, uid, ids, [])[0]
+        subscription_proxy = self.pool.get('training.subscription')
+        subscription_line_proxy = self.pool.get('training.subscription.line')
+        partner_obj = self.pool.get('res.partner')
+        partner_id = form['partner_id']
+        values = subscription_proxy.on_change_partner(cr, uid, [], partner_id)['value']
+        values.update({
+                'partner_id' : partner_id,
+            })
+        subscription_id = subscription_proxy.create(cr, uid, values, context=context)
+        partner = partner_obj.browse(cr, uid, form['partner_id'], context=context)
+        def_pricelist_id = partner.property_product_pricelist.id
+
+        masslines = self.pool.get('training.subscription.mass.line')
+        if form['job_ids']:
+            for job_id in form['job_ids']:
+                for line in form['line_ids']:
+                    val={'session_id':line}
+                    mlid = masslines.create(cr, uid, val)
+                    massline = masslines.browse(cr, uid, mlid, context=context)
+                    job = self.pool.get('res.partner.job').browse(cr, uid, job_id, context=context)
+                    values = subscription_line_proxy._get_values_from_wizard(cr, uid, subscription_id, job, massline, context=context)
+                    sl_id = subscription_line_proxy.create(cr, uid, values, context=context)
+        return {
+            'view_type': 'form',
+            "view_mode": 'form',
+            'res_model': 'training.subscription',
+            'view_id': self.pool.get('ir.ui.view').search(cr,uid,[('name','=','training.subscription.form')]),
+            'type': 'ir.actions.act_window',
+            'target': 'current',
+            'res_id' : int(subscription_id)
+        }
+
+training_subscription_session()
+
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
\ No newline at end of file

=== added file 'training/wizard/training_subscription_session.xml'
--- training/wizard/training_subscription_session.xml	1970-01-01 00:00:00 +0000
+++ training/wizard/training_subscription_session.xml	2011-03-17 11:17:58 +0000
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<openerp>
+	<data>
+	    <record model="ir.ui.view" id="training_subscription_session_form">
+	        <field name="name">training.subscription.session.form</field>
+	        <field name="model">training.subscription.session</field>
+	        <field name="type">form</field>
+	        <field name="arch" type="xml">
+	            <form string="Mass Subscription">
+	            	<separator string="Partner" colspan="4"/>
+	                <field name="partner_id" nolabel="1"  colspan="4" />
+	                <separator string="Contacts" colspan="4" />
+	                <field name="job_ids"  nolabel="1" colspan="4" domain="[('name', '=', partner_id),('state', '=', 'current')]" />
+	                <separator string="Sessions" colspan="2" />
+	                <field name="line_ids" nolabel="1" colspan="4" domain="[('state', 'in', ('opened','opened_confirmed'))]"/>
+	                <group colspan="2" col="2">
+	                    <button type="special" special="cancel" string="Cancel" icon="gtk-cancel"/>
+	                    <button type="object" name="make_subscription" string="Create Subscription" icon="gtk-apply"/>
+	                </group>
+	            </form>
+	        </field>
+	    </record>
+
+	    <act_window name="Create Subscriptions"
+			    res_model="training.subscription.session"
+			    src_model="training.session"
+			    view_mode="form"
+			    target="new"
+	            key2="client_action_multi"
+			    id="action_training_subscription_session"/>
+	</data>
+</openerp>

=== added file 'training/wizard/validate_course.py'
--- training/wizard/validate_course.py	1970-01-01 00:00:00 +0000
+++ training/wizard/validate_course.py	2011-03-17 11:17:58 +0000
@@ -0,0 +1,41 @@
+# -*- encoding: utf-8 -*-
+##############################################################################
+#
+#    OpenERP, Open Source Management Solution
+#    Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>). All Rights Reserved
+#    $Id$
+#
+#    This program is free software: you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation, either version 3 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License
+#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
+#
+##############################################################################
+
+import netsvc
+from osv import osv, fields
+
+class validate_courses(osv.osv_memory):
+    _name = 'validate.courses'
+
+    def validate_courses(self, cr, uid, ids, context=None):
+        if context is None:
+            context = {}
+        workflow = netsvc.LocalService('workflow')
+        proxy = self.pool.get('training.course')
+        for course in proxy.browse(cr, uid, context.get('active_ids',[]), context=context):
+            if course.state_course in ('pending','draft'):
+                workflow.trg_validate(uid, 'training.course', course.id, 'signal_validate', cr)
+        return {}
+
+validate_courses()
+
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

=== added file 'training/wizard/validate_course_view.xml'
--- training/wizard/validate_course_view.xml	1970-01-01 00:00:00 +0000
+++ training/wizard/validate_course_view.xml	2011-03-17 11:17:58 +0000
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="utf-8"?>
+<openerp>
+	<data>
+	    <record model="ir.ui.view" id="validate_courses_form">
+	        <field name="name">validate.courses.form</field>
+	        <field name="model">validate.courses</field>
+	        <field name="type">form</field>
+	        <field name="arch" type="xml">
+	            <form string="Validate Courses">
+	            	<label string="Do you want to validate the selected courses ?" />
+	            	<newline/>
+	                <group colspan="2" col="2">
+	                    <button type="special" special="cancel" string="Cancel" icon="gtk-cancel"/>
+	                    <button type="object" name="validate_courses" string="Validate Courses" icon="gtk-apply"/>
+	                </group>
+	            </form>
+	        </field>
+	    </record>
+
+	    <act_window name="Validate Course(s)"
+			    res_model="validate.courses"
+			    src_model="training.course"
+			    view_mode="form"
+			    target="new"
+	            key2="client_action_multi"
+			    id="action_validate_courses"/>
+	</data>
+</openerp>