Coveralls logob
Coveralls logo
  • Home
  • Features
  • Pricing
  • Docs
  • Sign In

OCA / manufacture / 187

15 Oct 2015 - 21:48 First build on 7.0 at 80.702%
187

Pull #18

travis-ci

Sébastien BEAU
[FIX] fix domain
Pull Request #18:

12 of 23 new or added lines in 1 file covered. (52.17%)

46 of 57 relevant lines covered (80.7%)

2.0 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

52.17
/mrp_workcenter_workorder_link/mrp.py
1
# -*- coding: utf-8 -*-
2
##############################################################################
3
#
4
#    Author: David BEAL
5
#    Copyright 2015 Akretion
6
#
7
#    This program is free software: you can redistribute it and/or modify
8
#    it under the terms of the GNU Affero General Public License as
9
#    published by the Free Software Foundation, either version 3 of the
10
#    License, or (at your option) any later version.
11
#
12
#    This program is distributed in the hope that it will be useful,
13
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
14
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
#    GNU Affero General Public License for more details.
16
#
17
#    You should have received a copy of the GNU Affero General Public License
18
#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
19
#
20
##############################################################################
21

22
from openerp.osv import orm, fields
3×
23

24
# States than we don't want to take account
25
STATIC_STATES = ['cancel', 'done']
3×
26

27
WORKCENTER_ACTION = {
3×
28
    'res_model': 'mrp.workcenter',
29
    'type': 'ir.actions.act_window',
30
    'target': 'current',
31
}
32

33

34
class MrpWorkcenter(orm.Model):
3×
35
    _inherit = 'mrp.workcenter'
3×
36

37
    _columns = {
3×
38
        'production_line_ids': fields.one2many(
39
            'mrp.production.workcenter.line',
40
            'workcenter_id',
41
            domain=[('state', 'not in', STATIC_STATES)],
42
            string='Work Orders'),
43
    }
44

45
    def _get_workcenter_line_domain(self, cr, uid, ids, context=None):
3×
NEW
46
        return [
!
47
            ('state', 'not in', STATIC_STATES),
48
            ('workcenter_id', 'in', ids),
49
            ]
50

51
    def button_workcenter_line(self, cr, uid, ids, context=None):
3×
NEW
52
        assert len(ids) == 1, 'You can open only an record'
!
NEW
53
        elm = self.browse(cr, uid, ids[0], context=context)
!
NEW
54
        domain = elm._get_workcenter_line_domain()
!
NEW
55
        return {
!
56
            'view_mode': 'tree,form',
57
            'name': "'%s' Operations" % elm.name,
58
            'res_model': 'mrp.production.workcenter.line',
59
            'type': 'ir.actions.act_window',
60
            'domain': domain,
61
            'target': 'current',
62
        }
63

64

65
class MrpProductionWorkcenterLine(orm.Model):
3×
66
    _inherit = 'mrp.production.workcenter.line'
3×
67
    _order = 'sequence ASC, name ASC'
3×
68

69
    def button_workcenter(self, cr, uid, ids, context=None):
3×
NEW
70
        assert len(ids) == 1, 'You can open only an record'
!
NEW
71
        elm = self.browse(cr, uid, ids[0], context=context)
!
NEW
72
        _, view_id = self.pool['ir.model.data'].get_object_reference(
!
73
            cr, uid, 'mrp', 'mrp_workcenter_view')
NEW
74
        action = {
!
75
            'view_id': view_id,
76
            'res_id': elm.workcenter_id.id,
77
            'name': "'%s' Workcenter" % elm.name,
78
            'view_mode': 'form',
79
        }
NEW
80
        action.update(WORKCENTER_ACTION)
!
NEW
81
        return action
!
Troubleshooting · Open an Issue · Sales · Support · ENTERPRISE · CAREERS · STATUS
BLOG · TWITTER · Legal & Privacy · Supported CI Services · What's a CI service? · Automated Testing

© 2019 Coveralls, LLC