1
# -*- coding: utf-8 -*-
2
#########################################################################
5
#########################################################################
7
# Copyright (C) 2009-2011 Akretion, Emmanuel Samyn #
9
#This program is free software: you can redistribute it and/or modify #
10
#it under the terms of the GNU General Public License as published by #
11
#the Free Software Foundation, either version 3 of the License, or #
12
#(at your option) any later version. #
14
#This program is distributed in the hope that it will be useful, #
15
#but WITHOUT ANY WARRANTY; without even the implied warranty of #
16
#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
17
#GNU General Public License for more details. #
19
#You should have received a copy of the GNU General Public License #
20
#along with this program. If not, see <http://www.gnu.org/licenses/>. #
21
#########################################################################
23
from osv import fields, osv
27
# Class to create a picking in from selected return lines
28
class exchange_from_returned_lines(osv.osv_memory):
29
_name='exchange_from_returned_lines.wizard'
30
_description='Wizard to create an exchange from selected return lines'
32
'exchange_line_ids' : fields.many2many('temp.exchange.line', 'exchange_rel_refund', 'wizard_id', 'temp_exchange_line_id', 'Selected exchange lines'),
35
# Get selected lines to add to exchange
36
def _get_selected_lines(self, cr, uid,context):
37
returned_line_ids = self.pool.get('crm.claim').read(cr, uid, context['active_id'], ['return_line_ids'])['return_line_ids']
38
returned_lines = self.pool.get('return.line').browse(cr, uid,returned_line_ids)
40
for line in returned_lines:
42
print "_get_selected : ",line.unit_sale_price
43
M2M.append(self.pool.get('temp.exchange.line').create(cr, uid, {
45
'returned_product_id' : line.product_id.id,
46
'returned_product_quantity' : line.product_returned_quantity,
47
'returned_prodlot_id' : line.prodlot_id.id,
48
'returned_unit_sale_price' : line.unit_sale_price,
53
'exchange_line_ids': _get_selected_lines,
56
# If "Cancel" button pressed
57
def action_cancel(self,cr,uid,ids,conect=None):
58
return {'type': 'ir.actions.act_window_close',}
60
# If "Create" button pressed
61
def action_create_exchange(self, cr, uid, ids, context=None):
62
for exchange in self.browse(cr, uid,ids):
63
claim_id = self.pool.get('crm.claim').browse(cr, uid, context['active_id'])
65
for line in exchange.exchange_line_ids:
66
print "for : ",line.returned_unit_sale_price
67
exchange_id = self.pool.get('product.exchange').create(cr, uid, {
70
'exchange_send_date': time.strftime('%Y-%m-%d %H:%M:%S'),
71
'returned_product' : line.returned_product_id.id,
72
'returned_product_serial' : line.returned_prodlot_id.id,
73
'returned_product_qty' : line.returned_product_quantity,
74
'returned_unit_sale_price' : line.returned_unit_sale_price,
75
'replacement_product' : line.replacement_product_id.id,
76
'replacement_product_serial' : line.replacement_prodlot_id.id,
77
'replacement_product_qty' : line.replacement_product_quantity,
78
'claim_return_id' : claim_id.id
81
return {'type': 'ir.actions.act_window_close',}
83
exchange_from_returned_lines()
85
#===== Temp exchange line
86
class temp_exchange_line(osv.osv_memory):
88
Class to handle a product exchange line
90
_name = "temp.exchange.line"
91
_description = "List of product to exchange"
93
'name': fields.char('Comment', size=128, help="To describe the line product problem"),
94
'returned_product_id': fields.many2one('product.product', 'Returned product', required=True),
95
'returned_product_quantity' : fields.float('Returned quantity', digits=(12,2), help="Quantity of product returned"),
96
'returned_unit_sale_price' : fields.float('Unit sale price', digits=(12,2),),
97
'returned_prodlot_id': fields.many2one('stock.production.lot', 'Returned serial/Lot'),
98
'replacement_product_id': fields.many2one('product.product', 'Replacement product', required=True),
99
'replacement_product_quantity' : fields.float('Replacement quantity', digits=(12,2), help="Replacement quantity"),
100
'replacement_prodlot_id': fields.many2one('stock.production.lot', 'Replacement serial/Lot'),
105
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: