~vauxoo/addons-vauxoo/6.0-trunk

« back to all changes in this revision

Viewing changes to sale_uncommitted_product/wizard/sale_double_validation_installer.py

  • Committer: Jose Antonio
  • Date: 2012-06-13 22:24:45 UTC
  • mto: This revision was merged to the branch mainline in revision 312.
  • Revision ID: jose@vauxoo.com-20120613222445-ybndycdaaw2puqyz

[ADD] Add wizard to add incidences from xls field

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: Humberto Arocha <hbto@vauxoo.com>
9
 
#    Planified by: Rafael Silva <rsilvam@vauxoo.com>
10
 
#    Audited by: Nhomar Hernandez <nhomar@vauxoo.com>
11
 
#############################################################################
12
 
#    This program is free software: you can redistribute it and/or modify
13
 
#    it under the terms of the GNU Affero General Public License as published by
14
 
#    the Free Software Foundation, either version 3 of the License, or
15
 
#    (at your option) any later version.
16
 
#
17
 
#    This program is distributed in the hope that it will be useful,
18
 
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
19
 
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20
 
#    GNU Affero General Public License for more details.
21
 
#
22
 
#    You should have received a copy of the GNU Affero General Public License
23
 
#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
24
 
##########################################################################
25
 
 
26
 
 
27
 
from openerp.osv import osv, fields
28
 
 
29
 
 
30
 
class sale_double_validation_installer(osv.TransientModel):
31
 
    _name = 'sale.double.validation.installer'
32
 
    _inherit = 'res.config'
33
 
    _columns = {
34
 
        'force_commit_group_id': fields.many2one('res.groups', 'Force Commit Group', required=False,
35
 
        help='''Setting this field to a group will only allow to that group to make Commitment Sale Orders without checking if complying with contraints.
36
 
        Leave blank to allow any group to force to'''),
37
 
        'commit_group_id': fields.many2one('res.groups', 'Commit Group', required=False,
38
 
        help='''Setting this field to a group will only allow to that group to make Commitment Sale Orders checking if complying with contraints.
39
 
        Leave blank to allow any group to commit to'''),
40
 
        'group_id': fields.many2one('res.groups', 'Approval Group', required=False,
41
 
        help='''Setting this field to a group will only allow to that group to approve Sale Orders.
42
 
        Leave blank to allow any group to approve to'''),
43
 
    }
44
 
 
45
 
    _defaults = {
46
 
        'group_id': False,
47
 
    }
48
 
 
49
 
    def execute(self, cr, uid, ids, context=None):
50
 
        data = self.read(cr, uid, ids, context=context)
51
 
 
52
 
        force_commit_group_id = data and data[
53
 
            0]['force_commit_group_id'] or False
54
 
        commit_group_id = data and data[0]['commit_group_id'] or False
55
 
        group_id = data and data[0]['group_id'] or False
56
 
 
57
 
        data_pool = self.pool.get('ir.model.data')
58
 
        transition_obj = self.pool.get('workflow.transition')
59
 
 
60
 
        force = data_pool._get_id(
61
 
            cr, uid, 'sale_uncommitted_product', 'trans_draft_force_commit')
62
 
        force_id = data_pool.browse(cr, uid, force, context=context).res_id
63
 
        transition_obj.write(cr, uid, force_id, {
64
 
                             'group_id': force_commit_group_id})
65
 
 
66
 
        commit = data_pool._get_id(
67
 
            cr, uid, 'sale_uncommitted_product', 'trans_draft_commit')
68
 
        commit_id = data_pool.browse(cr, uid, commit, context=context).res_id
69
 
        transition_obj.write(cr, uid, commit_id, {'group_id': commit_group_id})
70
 
 
71
 
        approval = data_pool._get_id(cr, uid, 'sale', 'trans_draft_router')
72
 
        approval_id = data_pool.browse(
73
 
            cr, uid, approval, context=context).res_id
74
 
        transition_obj.write(cr, uid, approval_id, {'group_id': group_id})
75
 
 
76
 
        return {}
77
 
 
78
 
 
79
 
 
80
 
 
81
 
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: