[IMP] update version in po(t) files
[odoo/odoo.git] / addons / project_mrp / mrp.py
1 # -*- encoding: utf-8 -*-
2 ##############################################################################
3 #
4 #    OpenERP, Open Source Management Solution   
5 #    Copyright (C) 2004-2008 Tiny SPRL (<http://tiny.be>). All Rights Reserved
6 #    $Id$
7 #
8 #    This program is free software: you can redistribute it and/or modify
9 #    it under the terms of the GNU General Public License as published by
10 #    the Free Software Foundation, either version 3 of the License, or
11 #    (at your option) any later version.
12 #
13 #    This program is distributed in the hope that it will be useful,
14 #    but WITHOUT ANY WARRANTY; without even the implied warranty of
15 #    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 #    GNU General Public License for more details.
17 #
18 #    You should have received a copy of the GNU General Public License
19 #    along with this program.  If not, see <http://www.gnu.org/licenses/>.
20 #
21 ##############################################################################
22
23 from osv import fields, osv, orm
24
25 class mrp_procurement(osv.osv):
26     _name = "mrp.procurement"
27     _inherit = "mrp.procurement"
28     
29     def action_produce_assign_service(self, cr, uid, ids, context={}):
30         for procurement in self.browse(cr, uid, ids):
31             sline = self.pool.get('sale.order.line')
32             sale_ids = sline.search(cr, uid, [('procurement_id','=',procurement.id)], context)
33             content = ''
34             l = None
35             project_id = None
36             for line in sline.browse(cr, uid, sale_ids, context=context):
37                 content += (line.notes or '')
38                 l = line
39                 if line.order_id.project_id:
40                     content+="\n\n"+line.order_id.project_id.complete_name
41
42             self.write(cr, uid, [procurement.id], {'state':'running'})
43             task_id = self.pool.get('project.task').create(cr, uid, {
44                 'name': procurement.origin+': '+procurement.name,
45                 'date_deadline': procurement.date_planned,
46                 'planned_hours': procurement.product_qty,
47                 'remaining_hours': procurement.product_qty,
48                 'user_id': procurement.product_id.product_manager.id,
49                 'notes': "b"+(l and l.order_id.note or ''),
50                 'procurement_id': procurement.id,
51                 'description': content,
52                 'date_deadline': procurement.date_planned,
53                 'state': 'draft',
54                 'partner_id': l and l.order_id.partner_id.id or False
55             })
56         return task_id
57 mrp_procurement()
58
59 # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
60