~unifield-team/unifield-wm/us-671-homere

« back to all changes in this revision

Viewing changes to sourcing/sale_order.py

UF-359 [ADD] Account override module integration

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# -*- coding: utf-8 -*-
2
 
##############################################################################
3
 
#
4
 
#    OpenERP, Open Source Management Solution
5
 
#    Copyright (C) 2014 TeMPO Consulting, MSF
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 osv import fields
23
 
from osv import osv
24
 
 
25
 
import netsvc
26
 
 
27
 
 
28
 
class sale_order(osv.osv):
29
 
    """
30
 
    Override the sale.order object to add some feature
31
 
    of the Order Sourcing Tool
32
 
    """
33
 
    _name = 'sale.order'
34
 
    _inherit = 'sale.order'
35
 
 
36
 
    _columns = {
37
 
        'sourcing_trace_ok': fields.boolean(
38
 
            string='Display sourcing logs',
39
 
        ),
40
 
        'sourcing_trace': fields.text(
41
 
            string='Sourcing logs',
42
 
            readonly=True,
43
 
        ),
44
 
    }
45
 
 
46
 
    # TODO: TO REFACTORE
47
 
    def do_order_confirm_method(self, cr, uid, ids, context=None):
48
 
        '''
49
 
        trigger the workflow
50
 
        '''
51
 
        # Some verifications
52
 
        if context is None:
53
 
            context = {}
54
 
        if isinstance(ids, (int, long)):
55
 
            ids = [ids]
56
 
 
57
 
        # objects
58
 
        wf_service = netsvc.LocalService("workflow")
59
 
        sol_obj = self.pool.get('sale.order.line')
60
 
 
61
 
        sol_ids = sol_obj.search(cr, uid, [('order_id', 'in', ids)], context=context)
62
 
        sol_obj.write(cr, uid, sol_ids, {'state': 'sourced'}, context=context)
63
 
 
64
 
        for order_id in ids:
65
 
            wf_service.trg_validate(uid, 'sale.order', order_id, 'order_confirm', cr)
66
 
 
67
 
        return True
68
 
 
69
 
sale_order()
70
 
 
71
 
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: