~camptocamp/c2c-rd-addons/8.0a

« back to all changes in this revision

Viewing changes to chricar_sale_internal_shippment/wizard/make_ship_internal.py

improved logging, improved import structure

Show diffs side-by-side

added added

removed removed

Lines of Context:
19
19
#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
20
20
#
21
21
##############################################################################
22
 
 
23
22
from osv import fields, osv
24
23
from tools.translate import _
25
 
import decimal_precision as dp
26
 
import netsvc
27
 
 
28
24
import pooler
29
 
 
30
25
from datetime import datetime, timedelta
31
26
from dateutil.relativedelta import relativedelta
32
 
import time
33
 
 
34
 
 
35
 
 
36
 
import sys
 
27
import netsvc
 
28
import logging
37
29
 
38
30
class sale_order(osv.osv):
39
31
    _inherit = "sale.order"
122
114
 
123
115
class sale_make_internal_ship_wizard(osv.osv_memory):
124
116
    _name = "sale.make.internal.ship.wizard"
125
 
    
 
117
    _logger = logging.getLogger(_name)
126
118
    _columns = {
127
119
        'location_id': fields.many2one('stock.location', 'Location', required=True, domain="[('usage', '=', 'internal')]"),
128
120
        'location_dest_id': fields.many2one('stock.location', 'Destination Location', required=True, domain="[('usage', '=', 'internal')]"),
143
135
 
144
136
    def make_internal_shippment(self, cr, uid, ids, context=None):
145
137
        data = self.read(cr, uid, ids)[0]
146
 
        print >> sys.stderr, 'data',data
 
138
        self._logger.debug('data `%s`', data)
147
139
        record_id = context and context.get('active_id', False)
148
140
        order_obj = self.pool.get('sale.order')
149
141
        order = order_obj.browse(cr, uid, record_id, context=context)
159
151
            
160
152
            #reloacte the source of out picking
161
153
        for i in order.picking_ids:
162
 
                if i.type== 'out' and i.state not in ['done', 'cancel']:
163
 
                    #stock_pick_obj = self.pool.get('stock.picking')
164
 
                    stock_move_obj = self.pool.get('stock.move')
165
 
                    loc_id = data['location_dest_id'][0]
166
 
                    for move in i.move_lines:
167
 
                        print >> sys.stderr, 'stock_pick write', loc_id, move.id
168
 
                        stock_move_obj.write(cr, uid, [move.id], {'location_id' :  loc_id } )
169
 
                        
 
154
            if i.type== 'out' and i.state not in ['done', 'cancel']:
 
155
                #stock_pick_obj = self.pool.get('stock.picking')
 
156
                stock_move_obj = self.pool.get('stock.move')
 
157
                loc_id = data['location_dest_id'][0]
 
158
                for move in i.move_lines:
 
159
                    self._logger.debug('stock_pick write `%s` `%s`', loc_id, move.id)
 
160
                    stock_move_obj.write(cr, uid, [move.id], {'location_id' :  loc_id } )
170
161
        order_obj.action_ship_internal_create(cr, uid, [record_id], data['location_id'][0], data['location_dest_id'][0])
171
162
                        
172
163
                        
173
 
        #print >>sys.stderr, 'make_internal_shipment ',internal, data, context
174
 
        # opene correct shipping window
 
164
        # open correct shipping window
175
165
        pool = pooler.get_pool(cr.dbname)
176
166
        mod_obj = pool.get('ir.model.data')
177
167
        act_obj = pool.get('ir.actions.act_window')
186
176
sale_make_internal_ship_wizard()
187
177
                            
188
178
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
189