~pexego/openobject-addons/6.1-pexego-sale_commission

« back to all changes in this revision

Viewing changes to employees_bom/mrp.py

  • Committer: Omar (pexego)
  • Date: 2012-07-27 08:40:22 UTC
  • Revision ID: omar@pexego.es-20120727084022-qp3ludpr3vsuyuf6
[ADD] Traceability modules ported to 6.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# -*- coding: utf-8 -*-
 
2
##############################################################################
 
3
#
 
4
#    Copyright (C) 2004-2011 Pexego Sistemas Informáticos. All Rights Reserved
 
5
#    $Omar Castiñeira Saavedra$
 
6
#    $Marta Vázquez Rodríguez$
 
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
from osv import osv, fields
 
23
 
 
24
class mrp_bom(osv.osv):
 
25
    _inherit = "mrp.bom"
 
26
    _columns = {
 
27
         'employees_ids': fields.many2many('hr.employee', 'employee_mrp_rel', 'bom_id','employee_id', 'Employees')
 
28
    }
 
29
    
 
30
mrp_bom()
 
31
 
 
32
class mrp_production(osv.osv):
 
33
    _inherit = "mrp.production"
 
34
    def explode_employees(self,cr,uid,ids,context=None):
 
35
        if context is None: context = {}
 
36
        employees = []
 
37
        for production in self.browse(cr,uid,ids):
 
38
            if production.bom_id.employees_ids:
 
39
                for employees_id in production.bom_id.employees_ids:
 
40
                    employees.append({
 
41
                        'employee_id': employees_id.id
 
42
                    })
 
43
        return employees
 
44
    def action_compute(self,cr,uid,ids,properties=[],context=None):
 
45
        if context is None: context = {}
 
46
        results = super(mrp_production, self).action_compute(cr, uid, ids, properties,context=context)
 
47
        empl = []
 
48
        production_obj = self.pool.get('mrp.production')
 
49
        bom_obj = self.pool.get('mrp.bom')
 
50
        man_power_obj = self.pool.get('mrp.production.manpower')
 
51
        for production in self.browse(cr,uid,ids):
 
52
            employees = production_obj.explode_employees(cr,uid,ids)
 
53
            for line in employees:
 
54
                line['production_id'] = production.id
 
55
                man_power_obj.create(cr, uid, line)
 
56
           
 
57
        return results
 
58
 
 
59
 
 
60
mrp_production()
 
61
 
 
62
     
 
63
            
 
64
           
 
 
b'\\ No newline at end of file'