1 # -*- encoding: utf-8 -*-
2 ##############################################################################
4 # OpenERP, Open Source Management Solution
5 # Copyright (C) 2004-2008 Tiny SPRL (<http://tiny.be>). All Rights Reserved
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.
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.
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/>.
21 ##############################################################################
23 from osv import fields, osv, orm
25 class mrp_procurement(osv.osv):
26 _name = "mrp.procurement"
27 _inherit = "mrp.procurement"
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)
36 for line in sline.browse(cr, uid, sale_ids, context=context):
37 content += (line.notes or '')
39 if line.order_id.project_id:
40 content+="\n\n"+line.order_id.project_id.complete_name
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,
54 'partner_id': l and l.order_id.partner_id.id or False
59 # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: