2
# -*- encoding: utf-8 -*-
3
###########################################################################
4
# Module Writen to OpenERP, Open Source Management Solution
5
# Copyright (C) OpenERP Venezuela (<http://openerp.com.ve>).
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.
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.
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
##########################################################################
27
from openerp.osv import osv, fields
30
class sale_double_validation_installer(osv.TransientModel):
31
_name = 'sale.double.validation.installer'
32
_inherit = 'res.config'
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'''),
49
def execute(self, cr, uid, ids, context=None):
50
data = self.read(cr, uid, ids, context=context)
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
57
data_pool = self.pool.get('ir.model.data')
58
transition_obj = self.pool.get('workflow.transition')
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})
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})
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})
81
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: