~vauxoo/addons-vauxoo/7.0_fix_account_move_validate_multi_wizard_dev_jorge

« back to all changes in this revision

Viewing changes to mrp_workcenter_management/model/mrp_workcenter.py

  • Committer: Humberto Arocha
  • Date: 2013-08-14 18:13:21 UTC
  • mfrom: (722.1.1 addons-vauxoo-7.0)
  • Revision ID: humbertoarocha@gmail.com-20130814181321-dcasl3py03v5enu6
[MERGE][mrp_workcenter_management] A new module for managing Workcenters has
landed Addons-Vauxoo in order to improve Manufacturing Management.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/python
 
2
# -*- encoding: utf-8 -*-
 
3
###############################################################################
 
4
#    Module Writen to OpenERP, Open Source Management Solution
 
5
#    Copyright (C) OpenERP Venezuela (<http://openerp.com.ve>).
 
6
#    All Rights Reserved
 
7
# Credits######################################################
 
8
#    Coded by: Yanina Aular <yanina.aular@vauxoo.com>
 
9
#              Katherine Zaoral <katherine.zaoral@vauxoo.com>
 
10
#    Planified by: Yanina Aular <yanina.aular@vauxoo.com>
 
11
#    Audited by: Humberto Arocha <humbertoarocha@gmail.com>
 
12
###############################################################################
 
13
#    This program is free software: you can redistribute it and/or modify
 
14
#    it under the terms of the GNU Affero General Public License as published
 
15
#    by the Free Software Foundation, either version 3 of the License, or
 
16
#    (at your option) any later version.
 
17
#
 
18
#    This program is distributed in the hope that it will be useful,
 
19
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
 
20
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
21
#    GNU Affero General Public License for more details.
 
22
#
 
23
#    You should have received a copy of the GNU Affero General Public License
 
24
#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
25
###############################################################################
 
26
 
 
27
from openerp.osv import fields, osv, orm
 
28
from openerp.tools.translate import _
 
29
 
 
30
# class mrp_workcenter(osv.Model):
 
31
#
 
32
#    _inherit = "mrp.workcenter"
 
33
#    _order = "sequence"
 
34
#    _columns = {
 
35
#        "sequence": fields.integer("Sequence")
 
36
#    }
 
37
#
 
38
#    _sql_constraints = [
 
39
#        ("sequence_uniq", "unique(sequence)", "The sequence of the workcenter must be unique!")
 
40
#    ]
 
41
 
 
42
 
 
43
class mrp_production_workcenter_line(osv.Model):
 
44
 
 
45
    _inherit = "mrp.production.workcenter.line"
 
46
    _columns = {
 
47
 
 
48
        'routing_id': fields.related('production_id', 'routing_id', type='many2one', relation='mrp.routing', string='Routing', store=True),
 
49
    }
 
50
 
 
51
    def _read_group_workcenter_ids(self, cr, uid, ids, domain, read_group_order=None, access_rights_uid=None, context=None):
 
52
 
 
53
        routing_obj = self.pool.get('mrp.routing')
 
54
        workcenter_obj = self.pool.get('mrp.workcenter')
 
55
 
 
56
        workcenter_ids = []
 
57
        if context.get('active_id', False):
 
58
            routing_brw = routing_obj.browse(cr, uid,
 
59
                                             context.get('active_id', False), context=context)
 
60
 
 
61
            for work_line in routing_brw.workcenter_lines:
 
62
                workcenter_ids.append(work_line.workcenter_id.id)
 
63
            workcenter_ids = map(lambda x: x, set(workcenter_ids))
 
64
            work_orders_ids = self.search(cr, uid, [("workcenter_id", "in", workcenter_ids), (
 
65
                "routing_id", "=", context.get('active_id', False))], context=context)
 
66
        else:
 
67
            workcenter_ids = workcenter_obj.search(
 
68
                cr, uid, [], context=context)
 
69
            work_orders_ids = self.search(cr, uid, [(
 
70
                "workcenter_id", "in", workcenter_ids)], context=context)
 
71
 
 
72
        lista_workcenter = workcenter_obj.browse(
 
73
            cr, uid, workcenter_ids, context=context)
 
74
       # lista_workcenter.sort(key=lambda x: x.sequence)
 
75
       # lista_workcenter.reverse()
 
76
 
 
77
        # Lista de tuplas (id, name)
 
78
        result = []
 
79
        for i in lista_workcenter:
 
80
            result.append((i.id, i.name))
 
81
 
 
82
        # Si se despliega o no
 
83
        visible = {}
 
84
        for i in workcenter_ids:
 
85
            visible[i] = False
 
86
 
 
87
        return result, visible
 
88
 
 
89
    _group_by_full = {
 
90
        'workcenter_id': _read_group_workcenter_ids,
 
91
    }