[REF] clean code, remove useless files, fix location for picking out

This commit is contained in:
Benoit Guillot
2013-06-17 16:25:22 +02:00
parent 9736103ffa
commit b3b623b675
22 changed files with 377 additions and 1455 deletions

View File

@@ -52,11 +52,6 @@ on this branch : https://code.launchpad.net/~akretion-team/openobject-addons/ope
'wizard/claim_make_picking_view.xml',
'wizard/claim_make_picking_from_picking_view.xml',
'wizard/returned_lines_from_serial_wizard_view.xml',
# 'wizard/returned_lines_from_invoice_wizard_view.xml',
# 'wizard/picking_from_returned_lines_wizard_view.xml',
# 'wizard/refund_from_returned_lines_wizard_view.xml',
# 'wizard/exchange_from_returned_lines_wizard_view.xml',
# 'wizard/picking_from_exchange_lines_wizard_view.xml',
'wizard/get_empty_serial_view.xml',
'crm_claim_rma_view.xml',
'security/ir.model.access.csv',

View File

@@ -4,7 +4,7 @@
# #
#########################################################################
# #
# Copyright (C) 2009-2011 Akretion, Raphaël Valyi, Sébastien Beau, #
# Copyright (C) 2009-2011 Akretion, Raphaël Valyi, Sébastien Beau, #
# Emmanuel Samyn, Benoît Guillot #
# #
#This program is free software: you can redistribute it and/or modify #
@@ -21,14 +21,13 @@
#along with this program. If not, see <http://www.gnu.org/licenses/>. #
#########################################################################
from osv import fields, osv
from openerp.osv import fields, orm, osv
from tools.translate import _
class account_invoice(osv.osv):
class account_invoice(orm.Model):
_inherit = "account.invoice"
_columns = {
'claim_id': fields.many2one('crm.claim', 'Claim'),
}
@@ -40,18 +39,28 @@ class account_invoice(osv.osv):
def _refund_cleanup_lines(self, cr, uid, lines, context=None):
if context is None: context = {}
inv_line_obj = self.pool.get('account.invoice.line')
claim_line_obj = self.pool.get('claim.line')
new_lines = []
if context.get('claim_line_ids') and lines and 'product_id' in lines[0]:#check if is an invoice_line
if context.get('claim_line_ids') and lines and 'product_id' in lines[0]:#check if there is an invoice_line
for claim_line_id in context.get('claim_line_ids'):
claim_info = self.pool.get('claim.line').read(cr, uid, claim_line_id[1], ['invoice_line_id', 'product_returned_quantity', 'refund_line_id'], context=context)
claim_info = claim_line_obj.read(cr, uid,
claim_line_id[1],
['invoice_line_id',
'product_returned_quantity',
'refund_line_id'],
context=context)
if not claim_info['refund_line_id']:
invoice_line_info = self.pool.get('account.invoice.line').read(cr, uid, claim_info['invoice_line_id'][0], context=context)
invoice_line_info =inv_line_obj.read(cr, uid,
claim_info['invoice_line_id'][0],
context=context)
invoice_line_info['quantity'] = claim_info['product_returned_quantity']
invoice_line_info['claim_line_id'] = [claim_line_id[1]]
new_lines.append(invoice_line_info)
if not new_lines:
#TODO use custom states to show button of this wizard or not instead of raise an error
raise osv.except_osv(_('Error !'), _('A refund has already been created for this claim !'))
raise osv.except_osv(_('Error !'),
_('A refund has already been created for this claim !'))
lines = new_lines
result = super(account_invoice, self)._refund_cleanup_lines(cr, uid, lines, context=context)
return result
@@ -62,8 +71,8 @@ class account_invoice(osv.osv):
result['claim_id'] = kwargs['context']['claim_id']
return result
class account_invoice_line(osv.osv):
class account_invoice_line(orm.Model):
_inherit = "account.invoice.line"
def create(self, cr, uid, vals, context=None):
@@ -71,7 +80,10 @@ class account_invoice_line(osv.osv):
if vals.get('claim_line_id'):
claim_line_id = vals['claim_line_id']
del vals['claim_line_id']
line_id = super(account_invoice_line, self).create(cr, uid, vals, context=context)
line_id = super(account_invoice_line, self).create(cr, uid, vals,
context=context)
if claim_line_id:
self.pool.get('claim.line').write(cr, uid, claim_line_id, {'refund_line_id': line_id}, context=context)
self.pool.get('claim.line').write(cr, uid, claim_line_id,
{'refund_line_id': line_id},
context=context)
return line_id

View File

@@ -4,8 +4,9 @@
# #
#########################################################################
# #
# Copyright (C) 2009-2011 Akretion, Raphaël Valyi, Sébastien Beau, #
# Emmanuel Samyn #
# Copyright (C) 2009-2013 Akretion #
# @ Authors : Raphaël Valyi, Sébastien Beau, Emmanuel Samyn, #
# Benoît GUILLOT <benoit.guillot@akretion.com> #
# #
#This program is free software: you can redistribute it and/or modify #
#it under the terms of the GNU General Public License as published by #
@@ -21,7 +22,7 @@
#along with this program. If not, see <http://www.gnu.org/licenses/>. #
#########################################################################
from osv import fields, osv
from openerp.osv import fields, orm, osv
from crm import crm
from datetime import datetime
from dateutil.relativedelta import relativedelta
@@ -29,8 +30,9 @@ import time
from tools.translate import _
from tools import DEFAULT_SERVER_DATE_FORMAT
#===== TO REFACTORED IN A GENERIC MODULE
class substate_substate(osv.osv):
#===== TO REFACTORED IN A GENERIC MODULE
class substate_substate(orm.Model):
"""
To precise a state (state=refused; substates= reason 1, 2,...)
"""
@@ -38,97 +40,134 @@ class substate_substate(osv.osv):
_description = "substate that precise a given state"
_columns = {
'name': fields.char('Sub state', size=128, required=True),
'substate_descr' : fields.text('Description', help="To give more information about the sub state"),
'substate_descr' : fields.text('Description',
help="To give more information about the sub state"),
# ADD OBJECT TO FILTER
}
substate_substate()
#=====
class claim_line(osv.osv):
class claim_line(orm.Model):
"""
Class to handle a product return line (corresponding to one invoice line)
"""
_name = "claim.line"
_description = "List of product to return"
# Method to calculate total amount of the line : qty*UP
def _line_total_amount(self, cr, uid, ids, field_name, arg,context):
res = {}
for line in self.browse(cr,uid,ids):
for line in self.browse(cr,uid,ids):
res[line.id] = line.unit_sale_price*line.product_returned_quantity
return res
return res
# def _get_claim_seq(self, cr, uid, ids, field_name, arg,context):
# res = {}
# for line in self.browse(cr,uid,ids):
# for line in self.browse(cr,uid,ids):
# res[line.id] = line.claim_id.sequence
# return res
# return res
_columns = {
'name': fields.char('Description', size=64,required=True),
# 'name': fields.function(_get_claim_seq, method=True, string='Claim n°', type='char', size=64,store=True),
'claim_origine': fields.selection([('none','Not specified'),
('legal','Legal retractation'),
('cancellation','Order cancellation'),
('damaged','Damaged delivered product'),
('damaged','Damaged delivered product'),
('error','Shipping error'),
('exchange','Exchange request'),
('lost','Lost during transport'),
('other','Other')], 'Claim Subject', required=True, help="To describe the line product problem"),
'claim_descr' : fields.text('Claim description', help="More precise description of the problem"),
#use the invoice line instead of the invoice
# 'invoice_id': fields.many2one('account.invoice', 'Invoice',help="The invoice related to the returned product"),
'product_id': fields.many2one('product.product', 'Product',help="Returned product"),
'product_returned_quantity' : fields.float('Quantity', digits=(12,2), help="Quantity of product returned"),
'unit_sale_price' : fields.float('Unit sale price', digits=(12,2), help="Unit sale price of the product. Auto filed if retrun done by invoice selection. BE CAREFUL AND CHECK the automatic value as don't take into account previous refounds, invoice discount, can be for 0 if product for free,..."),
'return_value' : fields.function(_line_total_amount, method=True, string='Total return', type='float', help="Quantity returned * Unit sold price",),
'prodlot_id': fields.many2one('stock.production.lot', 'Serial/Lot n°',help="The serial/lot of the returned product"),
'applicable_guarantee': fields.selection([('us','Company'),('supplier','Supplier'),('brand','Brand manufacturer')], 'Warranty type'),# METTRE CHAMP FONCTION; type supplier might generate an auto draft forward to the supplier
'guarantee_limit': fields.date('Warranty limit', help="The warranty limit is computed as: invoice date + warranty defined on selected product.", readonly=True),
'warning': fields.char('Warranty', size=64, readonly=True,help="If warranty has expired"), #select=1,
'warranty_type': fields.char('Warranty type', size=64, readonly=True,help="from product form"),
"warranty_return_partner" : fields.many2one('res.partner.address', 'Warranty return',help="Where the customer has to send back the product(s)"),
'claim_id': fields.many2one('crm.claim', 'Related claim',help="To link to the case.claim object"),
('other','Other')], 'Claim Subject',
required=True, help="To describe the line product problem"),
'claim_descr' : fields.text('Claim description',
help="More precise description of the problem"),
'product_id': fields.many2one('product.product',
'Product',
help="Returned product"),
'product_returned_quantity' : fields.float('Quantity', digits=(12,2),
help="Quantity of product returned"),
'unit_sale_price' : fields.float('Unit sale price', digits=(12,2),
help="Unit sale price of the product. Auto filed if retrun done by invoice selection. BE CAREFUL AND CHECK the automatic value as don't take into account previous refounds, invoice discount, can be for 0 if product for free,..."),
'return_value' : fields.function(_line_total_amount, method=True,
string='Total return', type='float',
help="Quantity returned * Unit sold price",),
'prodlot_id': fields.many2one('stock.production.lot', 'Serial/Lot n°',
help="The serial/lot of the returned product"),
'applicable_guarantee': fields.selection([('us','Company'),
('supplier','Supplier'),
('brand','Brand manufacturer')],
'Warranty type'),# METTRE CHAMP FONCTION; type supplier might generate an auto draft forward to the supplier
'guarantee_limit': fields.date('Warranty limit',
help="The warranty limit is computed as: "
"invoice date + warranty defined on selected product.",
readonly=True),
'warning': fields.char('Warranty', size=64, readonly=True,
help="If warranty has expired"), #select=1,
'warranty_type': fields.char('Warranty type', size=64, readonly=True,
help="from product form"),
"warranty_return_partner" : fields.many2one('res.partner.address',
'Warranty return',
help="Where the customer has "
"to send back the product(s)"),
'claim_id': fields.many2one('crm.claim', 'Related claim',
help="To link to the case.claim object"),
'state' : fields.selection([('draft','Draft'),
('refused','Refused'),
('confirmed','Confirmed, waiting for product'),
('in_to_control','Received, to control'),
('in_to_treate','Controlled, to treate'),
('treated','Treated')], 'State'),
'substate_id': fields.many2one('substate.substate', 'Sub state',help="Select a sub state to precise the standard state. Example 1: state = refused; substate could be warranty over, not in warranty, no problem,... . Example 2: state = to treate; substate could be to refund, to exchange, to repair,..."),
'last_state_change': fields.date('Last change', help="To set the last state / substate change"),
'invoice_line_id': fields.many2one('account.invoice.line', 'Invoice Line', help='The invoice line related to the returned product'),
'refund_line_id': fields.many2one('account.invoice.line', 'Refund Line', help='The refund line related to the returned product'),
'move_in_id': fields.many2one('stock.move', 'Move Line from picking in', help='The move line related to the returned product'),
'move_out_id': fields.many2one('stock.move', 'Move Line from picking out', help='The move line related to the returned product'),
'substate_id': fields.many2one('substate.substate', 'Sub state',
help="Select a sub state to precise the "
"standard state. Example 1: state = refused; "
"substate could be warranty over, not in warranty, "
"no problem,... . Example 2: state = to treate; "
"substate could be to refund, to exchange, to repair,..."),
'last_state_change': fields.date('Last change',
help="To set the last state / substate change"),
'invoice_line_id': fields.many2one('account.invoice.line', 'Invoice Line',
help="The invoice line related to the "
"returned product"),
'refund_line_id': fields.many2one('account.invoice.line', 'Refund Line',
help="The refund line related to the "
"returned product"),
'move_in_id': fields.many2one('stock.move', 'Move Line from picking in',
help='The move line related to the returned product'),
'move_out_id': fields.many2one('stock.move', 'Move Line from picking out',
help='The move line related to the returned product'),
}
_defaults = {
'state': lambda *a: 'draft',
'name': lambda *a: 'none',
}
}
# Method to calculate warranty limit
def set_warranty_limit(self, cr, uid, ids, context, claim_line):
date_invoice = claim_line.invoice_line_id.invoice_id.date_invoice
if date_invoice:
warning = "Valid"
if claim_line.claim_id.claim_type == 'supplier':
if claim_line.prodlot_id :
limit = (datetime.strptime(date_invoice, DEFAULT_SERVER_DATE_FORMAT) + relativedelta(months=int(claim_line.product_id.seller_ids[0].warranty_duration))).strftime(DEFAULT_SERVER_DATE_FORMAT) # TO BE IMPLEMENTED !!!
else :
limit = (datetime.strptime(date_invoice, DEFAULT_SERVER_DATE_FORMAT) + relativedelta(months=int(claim_line.product_id.seller_ids[0].warranty_duration))).strftime(DEFAULT_SERVER_DATE_FORMAT)
if not date_invoice:
raise osv.except_osv(_('Error !'), _('Cannot find any date for invoice ! '
'Must be a validated invoice !'))
warning = "Valid"
if claim_line.claim_id.claim_type == 'supplier':
warranty_duration = claim_line.product_id.seller_ids[0].warranty_duration
if claim_line.prodlot_id :
limit = (datetime.strptime(date_invoice,
DEFAULT_SERVER_DATE_FORMAT) + \
relativedelta(months=int(warranty_duration))).strftime(DEFAULT_SERVER_DATE_FORMAT) # TO BE IMPLEMENTED !!!
else :
limit = (datetime.strptime(date_invoice, DEFAULT_SERVER_DATE_FORMAT) + relativedelta(months=int(claim_line.product_id.warranty))).strftime(DEFAULT_SERVER_DATE_FORMAT)
if limit < claim_line.claim_id.date:
warning = 'Expired'
self.write(cr,uid,ids,{
'guarantee_limit' : limit,
'warning' : warning,
})
else:
raise osv.except_osv(_('Error !'), _('Cannot find any date for invoice ! Must be a validated invoice !'))
limit = (datetime.strptime(date_invoice,
DEFAULT_SERVER_DATE_FORMAT) + \
relativedelta(months=int(warranty_duration))).strftime(DEFAULT_SERVER_DATE_FORMAT)
else :
limit = (datetime.strptime(date_invoice,
DEFAULT_SERVER_DATE_FORMAT) + \
relativedelta(months=int(claim_line.product_id.warranty))).strftime(DEFAULT_SERVER_DATE_FORMAT)
if limit < claim_line.claim_id.date:
warning = 'Expired'
self.write(cr,uid,ids,{
'guarantee_limit' : limit,
'warning' : warning,
})
return True
# Method to calculate warranty return address
@@ -143,7 +182,7 @@ class claim_line(osv.osv):
else:
warranty_type = 'company'
return_address = seller.warranty_return_address.id
# if return_partner == 'company':
# if return_partner == 'company':
# return_address = self._get_partner_address(cr, uid, ids, context,claim_line.claim_id.company_id.partner_id)[0]
# elif return_partner == 'supplier':
# return_address = self._get_partner_address(cr, uid, ids, context,claim_line.product_id.seller_ids[0].name)[0]
@@ -162,7 +201,7 @@ class claim_line(osv.osv):
# return True
#raise osv.except_osv(_('Error !'), _('Cannot find any warranty return partner for this product !'))
else :
else :
warranty_type = 'company'
if claim_line.claim_id.company_id.crm_return_address_id:
return_address = [claim_line.claim_id.company_id.crm_return_address_id.id]
@@ -172,10 +211,11 @@ class claim_line(osv.osv):
#TODO fix me use default address
# self.write(cr,uid,ids,{'warranty_return_partner':1,'warranty_type': 'company'})
# return True
#raise osv.except_osv(_('Error !'), _('Cannot find any supplier for this product !'))
self.write(cr,uid,ids,{'warranty_return_partner':return_address,'warranty_type':warranty_type})
#raise osv.except_osv(_('Error !'), _('Cannot find any supplier for this product !'))
self.write(cr,uid,ids,{'warranty_return_partner': return_address,
'warranty_type': warranty_type})
return True
# Method to calculate warranty limit and validity
def set_warranty(self, cr, uid, ids,context=None):
for claim_line in self.browse(cr, uid, ids, context=context):
@@ -184,79 +224,32 @@ class claim_line(osv.osv):
self.set_warranty_return_address(cr, uid, ids, context, claim_line)
else:
raise osv.except_osv(_('Error !'), _('PLEASE SET PRODUCT & INVOICE!'))
return True
return True
#TODO add the option split the claim_line in order to manage the same product separately
claim_line()
#===== deprecated everything is based on the claim_line so product_exchange is useless
#class product_exchange(osv.osv):
# """
# Class to manage product exchanges history
# """
# _name = "product.exchange"
# _description = "exchange history line"
#
# # Method to calculate total amount of the line : qty*UP
# def total_amount_returned(self, cr, uid, ids, field_name, arg,context):
# res = {}
# for line in self.browse(cr,uid,ids):
# res[line.id] = line.returned_unit_sale_price*line.returned_product_qty
# return res
# # Method to calculate total amount of the line : qty*UP
# def total_amount_replacement(self, cr, uid, ids, field_name, arg,context):
# res = {}
# for line in self.browse(cr,uid,ids):
# res[line.id] = line.replacement_unit_sale_price*line.replacement_product_qty
# return res
# # Method to get the replacement product unit price
# def get_replacement_price(self, cr, uid, ids, field_name, arg,context):
# res = {}
# for line in self.browse(cr,uid,ids):
# res[line.id] = line.replacement_product.list_price
# return res
#
# _columns = {
# 'name': fields.char('Comment', size=128, required=True),
# 'exchange_send_date' : fields.date('Exchange date'),
# 'returned_product' : fields.many2one('product.product', 'Returned product', required=True), # ADD FILTER ON RETURNED PROD
# 'returned_product_serial' : fields.many2one('stock.production.lot', 'Returned serial/Lot n°'),
# 'returned_product_qty' : fields.float('Returned quantity', digits=(12,2), help="Quantity of product returned"),
# 'replacement_product' : fields.many2one('product.product', 'Replacement product', required=True),
# 'replacement_product_serial' : fields.many2one('stock.production.lot', 'Replacement serial/Lot n°'),
# 'replacement_product_qty' : fields.float('Replacement quantity', digits=(12,2), help="Quantity of product replaced"),
# 'claim_return_id' : fields.many2one('crm.claim', 'Related claim'), # To link to the case.claim object
# 'selected' : fields.boolean('s', help="Check to select"),
# 'state' : fields.selection([('draft','Draft'),
# ('confirmed','Confirmed'),
# ('to_send','To send'),
# ('sent','Sent')], 'State'),
# 'returned_unit_sale_price' : fields.float('Unit sale price', digits=(12,2)),
# 'returned_value' : fields.function(total_amount_returned, method=True, string='Total return', type='float', help="Quantity exchanged * Unit sold price",),
# 'replacement_unit_sale_price' : fields.function(get_replacement_price, method=True, string='Unit sale price', type='float',),
# 'replacement_value' : fields.function(total_amount_replacement, method=True, string='Total return', type='float', help="Quantity replaced * Unit sold price",),
# }
# _defaults = {
# 'state': lambda *a: 'draft',
# }
#
#product_exchange()
#==========
class crm_claim(osv.osv):
class crm_claim(orm.Model):
_inherit = 'crm.claim'
_columns = {
'number': fields.char('Number', size=128,readonly=True,states={'draft': [('readonly', False)]},required=True, help="Company internal claim unique number"),
'number': fields.char('Number', size=128,
readonly=True,
states={'draft': [('readonly', False)]},
required=True,
help="Company internal claim unique number"),
'claim_type': fields.selection([('customer','Customer'),
('supplier','Supplier'),
('other','Other')], 'Claim type', required=True, help="customer = from customer to company ; supplier = from company to supplier"),
('supplier','Supplier'),
('other','Other')],
'Claim type', required=True,
help="customer = from customer to company ; "
"supplier = from company to supplier"),
'claim_line_ids' : fields.one2many('claim.line', 'claim_id', 'Return lines'),
'product_exchange_ids': fields.one2many('product.exchange', 'claim_return_id', 'Product exchanges'),
# Aftersale outsourcing
'product_exchange_ids': fields.one2many('product.exchange',
'claim_return_id',
'Product exchanges'),
# Aftersale outsourcing
# 'in_supplier_picking_id': fields.many2one('stock.picking', 'Return To Supplier Picking', required=False, select=True),
# 'out_supplier_picking_id': fields.many2one('stock.picking', 'Return From Supplier Picking', required=False, select=True),
@@ -264,56 +257,50 @@ class crm_claim(osv.osv):
'planned_revenue': fields.float('Expected revenue'),
'planned_cost': fields.float('Expected cost'),
'real_revenue': fields.float('Real revenue'), # A VOIR SI COMPTA ANA ou lien vers compte ana ?
'real_cost': fields.float('Real cost'), # A VOIR SI COMPTA ANA ou lien vers compte ana ?
'real_cost': fields.float('Real cost'), # A VOIR SI COMPTA ANA ou lien vers compte ana ?
'invoice_ids': fields.one2many('account.invoice', 'claim_id', 'Refunds'),
'picking_ids': fields.one2many('stock.picking', 'claim_id', 'RMA'),
'invoice_id': fields.many2one('account.invoice', 'Invoice', help='Related invoice'),
'warehouse_id': fields.many2one('stock.warehouse', 'Warehouse', required=True),
'invoice_id': fields.many2one('account.invoice', 'Invoice',
help='Related invoice'),
'warehouse_id': fields.many2one('stock.warehouse', 'Warehouse',
required=True),
}
_defaults = {
'number': lambda obj, cr, uid, context: obj.pool.get('ir.sequence').get(cr, uid, 'crm.claim'),
'claim_type': lambda *a: 'customer',
'warehouse_id': lambda *a: 1,
}
# #===== Method to select all returned lines =====
# def select_all(self,cr, uid, ids,context):
# return_obj = self.pool.get('claim.line')
# for line in self.browse(cr,uid,ids)[0].claim_line_ids:
# return_obj.write(cr,uid,line.id,{'selected':True})
# return True
# #===== Method to unselect all returned lines =====
# def unselect_all(self,cr, uid, ids,context):
# return_obj = self.pool.get('claim.line')
# for line in self.browse(cr,uid,ids)[0].claim_line_ids:
# return_obj.write(cr,uid,line.id,{'selected':False})
# return True
# === deprecated if we use the refund wizard of the account module ===
# def refund(self, cr, uid, ids, context=None):
# mod_obj = self.pool.get('ir.model.data')
# xml_id = 'action_account_invoice_refund'
# result = mod_obj.get_object_reference(cr, uid, 'account', xml_id)
# id = result and result[1] or False
# result = act_obj.read(cr, uid, id, context=context)
# print 'result', result
# return result
def onchange_partner_id(self, cr, uid, ids, part, email=False):
res = super(crm_claim, self).onchange_partner_id(cr, uid, ids, part, email=email)
if not part:
return res
part_type = self.pool['res.partner'].read(cr, uid, part,
['customer', 'supplier'])
if part_type['customer']:
res['value']['claim_type'] = 'customer'
elif part_type['supplier']:
res['value']['claim_type'] = 'supplier'
return res
def onchange_partner_address_id(self, cr, uid, ids, add, email=False):
res = super(crm_claim, self).onchange_partner_address_id(cr, uid, ids, add, email=email)
if add:
if not res['value']['email_from'] or not res['value']['partner_phone']:
address = self.pool.get('res.partner.address').browse(cr, uid, add)
for other_add in address.partner_id.address:
if other_add.email and not res['value']['email_from']:
res['value']['email_from'] = other_add.email
if other_add.phone and not res['value']['partner_phone']:
res['value']['partner_phone'] = other_add.phone
if not add:
return res
if not res['value']['email_from'] or not res['value']['partner_phone']:
address = self.pool.get('res.partner.address').browse(cr, uid, add)
for other_add in address.partner_id.address:
if other_add.email and not res['value']['email_from']:
res['value']['email_from'] = other_add.email
if other_add.phone and not res['value']['partner_phone']:
res['value']['partner_phone'] = other_add.phone
return res
def onchange_invoice_id(self, cr, uid, ids, invoice_id, context=None):
invoice_line_obj = self.pool.get('account.invoice.line')
invoice_line_ids = invoice_line_obj.search(cr, uid, [('invoice_id', '=', invoice_id)])
invoice_line_ids = invoice_line_obj.search(cr, uid,
[('invoice_id', '=', invoice_id)],
context=context)
claim_lines = []
for invoice_line in invoice_line_obj.browse(cr,uid,invoice_line_ids):
# claim_line_obj = self.pool.get('claim.line')
@@ -331,6 +318,3 @@ class crm_claim(osv.osv):
# line.set_warranty()
return {'value' : {'claim_line_ids' : claim_lines}}
crm_claim()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@@ -50,7 +50,7 @@
<group expand="0" string="More">
<field name="last_state_change" select='1'/>
<field name="guarantee_limit" select='1'/>
<field name="return_value" select='1'/>
<field name="return_value" select='1'/>
<field name="name" select='1'/>
</group>
<newline/>
@@ -82,7 +82,7 @@
<field name="substate_id"/>
<field name="name"/>
<field name="prodlot_id"/>
<field name="warning"/>
<field name="warning"/>
<field name="product_returned_quantity"/>
<field name="claim_origine"/>
<field name="refund_line_id"/>
@@ -102,7 +102,7 @@
<separator string="Returned good" colspan="4"/>
<group col="6" colspan="4">
<field name="invoice_line_id"/> <!-- domain="[('type', '=', 'out_invoice')]" -->
<field name="product_id"/>
<field name="product_id"/>
<field name="prodlot_id"/>
<field name="product_returned_quantity"/>
<field name="unit_sale_price"/>
@@ -155,10 +155,10 @@
<field name="arch" type="xml">
<form string="Picking follow">
<field name="picking_id"/>
<field name="related_picking_state"/>
<field name="related_picking_state"/>
<field name="related_picking_due_date"/>
<field name="related_picking_delivered_date"/>
<field name="name"/>
<field name="related_picking_delivered_date"/>
<field name="name"/>
</form>
</field>
</record>
@@ -225,32 +225,38 @@
<field name="description" position="after">
<group name="Product Return" colspan="4">
<separator string="Product Return" colspan="4"/>
<field name="invoice_id" colspan="1" on_change="onchange_invoice_id(invoice_id, context)" domain="[('partner_id','=',partner_id)]" />
<button name="%(action_create_return_serial)d" string="Mass return from serial/lot n°" states="draft,open" type="action" target="new"/>
<field name="invoice_id" colspan="1"
on_change="onchange_invoice_id(invoice_id, context)"
domain="[('partner_id','=',partner_id)]" />
<button name="%(action_create_return_serial)d"
string="Mass return from serial/lot n°"
states="draft,open" type="action" target="new"/>
<field name="claim_line_ids" nolabel="1" colspan="3"/>
</group>
<group col="4" colspan="4" attrs="{'invisible':[('state', '&lt;&gt;','open')]}">
<group col="4" colspan="4"
attrs="{'invisible':[('state', '&lt;&gt;','open')]}">
<separator string="Action" colspan="4" />
<button name="%(action_claim_picking_in)d"
string="New picking IN" states="open"
type="action" target="new"
context="{'warehouse_id': warehouse_id,
'partner_id': partner_id}"/>
'partner_id': partner_id,
'claim_type': claim_type,
'claim_id': id}"/>
<button name="%(action_claim_picking_out)d"
string="New picking OUT" states="open"
type="action" target="new"
context="{'warehouse_id': warehouse_id,
'partner_id': partner_id}"/>
'partner_id': partner_id,
'claim_type': claim_type,
'claim_id': id}"/>
<button name="%(action_claim_picking_loss)d"
string="New Product Loss" states="open"
type="action" target="new"
context="{'warehouse_id': warehouse_id,
'partner_id': partner_id}"/>
'partner_id': partner_id,
'claim_type': claim_type,
'claim_id': id}"/>
<button name="%(account.action_account_invoice_refund)d"
type='action' string='New Refund'
states='open' icon="gtk-execute"
@@ -259,6 +265,7 @@
'claim_line_ids': claim_line_ids,
'description': name,
'claim_id': id,
'claim_type': claim_type
}"/>
</group>
</field>
@@ -277,60 +284,60 @@
</field>
</field>
</record>
<!-- Right side link to orders -->
<act_window
<act_window
context="{'search_default_partner_id': [partner_id]}"
id="act_crm_claim_rma_sale_orders"
name="Partner sale orders"
res_model="sale.order"
id="act_crm_claim_rma_sale_orders"
name="Partner sale orders"
res_model="sale.order"
src_model="crm.claim"/>
<!-- Right side link to invoices -->
<act_window
<act_window
context="{'search_default_partner_id': [partner_id],}"
domain="[('type', '=', 'out_invoice')]"
id="act_crm_claim_rma_invoice_out"
name="Partner invoices out"
res_model="account.invoice"
id="act_crm_claim_rma_invoice_out"
name="Partner invoices out"
res_model="account.invoice"
src_model="crm.claim"/>
<!-- Right side link to invoices -->
<act_window
<act_window
context="{'search_default_partner_id': [partner_id],}"
domain="[('type', '=', 'in_invoice')]"
id="act_crm_claim_rma_invoice_in"
name="Partner invoices in"
res_model="account.invoice"
id="act_crm_claim_rma_invoice_in"
name="Partner invoices in"
res_model="account.invoice"
src_model="crm.claim"/>
<!-- Right side link to refunds -->
<act_window
<act_window
context="{'search_default_partner_id': [partner_id],}"
domain="[('type', '=', 'out_refund')]"
id="act_crm_claim_rma_refunds_out"
name="Partner refunds out"
res_model="account.invoice"
src_model="crm.claim"/>
id="act_crm_claim_rma_refunds_out"
name="Partner refunds out"
res_model="account.invoice"
src_model="crm.claim"/>
<!-- Right side link to refunds -->
<act_window
<act_window
context="{'search_default_partner_id': [partner_id],}"
domain="[('type', '=', 'in_refund')]"
id="act_crm_claim_rma_refunds_in"
name="Partner refunds in"
res_model="account.invoice"
src_model="crm.claim"/>
<!-- Right side link to picking in -->
<act_window
id="act_crm_claim_rma_refunds_in"
name="Partner refunds in"
res_model="account.invoice"
src_model="crm.claim"/>
<!-- Right side link to picking in -->
<act_window
domain="[('type', '=', 'in'),('partner_id', 'in', [partner_id])]"
id="act_crm_claim_rma_picking_in"
name="Partner picking IN"
res_model="stock.picking"
src_model="crm.claim"/>
id="act_crm_claim_rma_picking_in"
name="Partner picking IN"
res_model="stock.picking"
src_model="crm.claim"/>
<!-- Right side link to picking out -->
<act_window
<act_window
domain="[('type', '=', 'out'),('partner_id', 'in', [partner_id])]"
id="act_crm_claim_rma_picking_out"
name="Partner picking OUT"
res_model="stock.picking"
src_model="crm.claim"/>
id="act_crm_claim_rma_picking_out"
name="Partner picking OUT"
res_model="stock.picking"
src_model="crm.claim"/>
<!-- act_window
@@ -338,16 +345,14 @@
context="{'search_default_account_id':[active_id], 'search_default_unreconciled':1, 'default_account_id': active_id}"
src_model="account.account"/>
<act_window domain="[('reconcile_id', '=', active_id)]" id="act_account_acount_move_line_reconcile_open"
<act_window domain="[('reconcile_id', '=', active_id)]" id="act_account_acount_move_line_reconcile_open"
name="Reconciled entries" res_model="account.move.line" src_model="account.move.reconcile"/ -->
<!-- Menu -->
<record model="ir.actions.act_window" id="crm_claim.crm_case_categ_claim0">
<field name="context">{'search_default_section_id': section_id, "search_default_user_id":uid, "stage_type":'claim'}</field>
</record>
<!-- return lines action -->
<record model="ir.actions.act_window" id="act_crm_case_claim_lines">
<field name="name">Claim lines</field>
@@ -366,9 +371,14 @@
<!-- field name="view_id" ref="crm.crm_case_categ_tree-view"/ -->
</record>
<!-- Menu -->
<menuitem name="Return lines" id="menu_crm_case_claims_claim_lines"
parent="base.menu_aftersale" action="act_crm_case_claim_lines" sequence="2"/>
<menuitem name="Returned line substates" id="menu_crm_case_claims_claim_line_substates"
parent="crm_claim.menu_config_claim" action="act_crm_claim_substates" sequence="2"/>
<menuitem name="Return lines"
id="menu_crm_case_claims_claim_lines"
parent="base.menu_aftersale"
action="act_crm_case_claim_lines"
sequence="2"/>
<menuitem name="Returned line substates"
id="menu_crm_case_claims_claim_line_substates"
parent="crm_claim.menu_config_claim"
action="act_crm_claim_substates" sequence="2"/>
</data>
</openerp>

View File

@@ -124,8 +124,8 @@ msgstr "Produit retourné"
#. module: crm_claim_rma
#: view:claim_make_picking.wizard:0
#: view:claim_make_picking_from_picking.wizard:0
msgid "Create picking"
msgstr "Créer expédition/réception"
msgid "Validate"
msgstr "Valider"
#. module: crm_claim_rma
#: view:claim.line:0
@@ -607,8 +607,8 @@ msgstr "Reconditionnement"
#. module: crm_claim_rma
#: view:claim_make_picking.wizard:0
msgid "Select exchange lines to add in picking"
msgstr "Selectionner les lignes à ajouter dans l'expédition/réception"
msgid "Select exchange lines to treat (don't modify them, do it in the picking)"
msgstr "Selectionner les lignes à traiter (ne pas les modifer ici, le faire dans l'expédition/réception)"
#. module: crm_claim_rma
#: field:returned_lines_from_serial.wizard,prodlot_id_1:0

View File

@@ -21,13 +21,18 @@
#along with this program. If not, see <http://www.gnu.org/licenses/>. #
#########################################################################
from osv import fields, osv
from openerp.osv import fields, orm
class res_company(osv.osv):
class res_company(orm.Model):
_inherit = "res.company"
_columns = {
'crm_return_address_id': fields.many2one('res.partner.address', 'Crm return address', help="Default address where the customers has to send back the returned product in a crm claim. If empty the address is the company address"),
'crm_return_address_id': fields.many2one('res.partner.address',
'Crm return address',
help="Default address where the "
"customers has to send back the "
"returned product in a crm claim. "
"If empty the address is the company address"),
}
res_company()

View File

@@ -4,7 +4,7 @@
# #
#########################################################################
# #
# Copyright (C) 2009-2011 Akretion, Raphaël Valyi, Sébastien Beau, #
# Copyright (C) 2009-2011 Akretion, Raphaël Valyi, Sébastien Beau, #
# Emmanuel Samyn, Benoît Guillot #
# #
#This program is free software: you can redistribute it and/or modify #
@@ -21,41 +21,47 @@
#along with this program. If not, see <http://www.gnu.org/licenses/>. #
#########################################################################
from osv import fields, osv
from openerp.osv import fields, orm
class stock_picking(osv.osv):
class stock_picking(orm.Model):
_inherit = "stock.picking"
_columns = {
'claim_id': fields.many2one('crm.claim', 'Claim'),
'claim_picking': fields.boolean('Picking from Claim'),
}
class stock_warehouse(osv.osv):
class stock_warehouse(orm.Model):
_inherit = "stock.warehouse"
_columns = {
'lot_rma_id': fields.many2one('stock.location', 'Location RMA'),
'lot_carrier_loss_id': fields.many2one('stock.location', 'Location Carrier Loss'),
'lot_breakage_loss_id': fields.many2one('stock.location', 'Location Breakage Loss'),
'lot_refurbish_id': fields.many2one('stock.location', 'Location Refurbish'),
'lot_rma_id': fields.many2one('stock.location',
'Location RMA'),
'lot_carrier_loss_id': fields.many2one('stock.location',
'Location Carrier Loss'),
'lot_breakage_loss_id': fields.many2one('stock.location',
'Location Breakage Loss'),
'lot_refurbish_id': fields.many2one('stock.location',
'Location Refurbish'),
}
#This part concern the case of a wrong picking out. We need to create a new stock_move in a micking already open.
#In order to don't have to confirm the stock_move we override the create and confirm it at the creation only for this case
class stock_move(osv.osv):
class stock_move(orm.Model):
_inherit = "stock.move"
def create(self, cr, uid, vals, context=None):
move_id = super(stock_move, self).create(cr, uid, vals, context=context)
if vals.get('picking_id'):
picking = self.pool.get('stock.picking').browse(cr, uid, vals['picking_id'], context=context)
picking = self.pool.get('stock.picking').browse(cr, uid,
vals['picking_id'],
context=context)
if picking.claim_picking and picking.type == u'in':
move = self.write(cr, uid, move_id, {'state': 'confirmed'}, context=context)
move = self.write(cr, uid, move_id, {'state': 'confirmed'},
context=context)
return move_id

View File

@@ -4,8 +4,8 @@
# #
#########################################################################
# #
# Copyright (C) 2009-2011 Akretion, Raphaël Valyi, Sébastien Beau, #
# Emmanuel Samyn #
# Copyright (C) 2009-2011 Akretion, Raphaël Valyi, Sébastien Beau, #
# Emmanuel Samyn #
# #
#This program is free software: you can redistribute it and/or modify #
#it under the terms of the GNU General Public License as published by #
@@ -22,13 +22,7 @@
#########################################################################
import returned_lines_from_serial
#import returned_lines_from_invoice
#import picking_from_returned_lines
#import refund_from_returned_lines
#import exchange_from_returned_lines
#import picking_from_exchange_lines
import get_empty_serial
import claim_make_picking
import account_invoice_refund
import claim_make_picking_from_picking

View File

@@ -21,20 +21,30 @@
#along with this program. If not, see <http://www.gnu.org/licenses/>. #
#########################################################################
from osv import fields, osv
from openerp.osv import fields, orm, osv
import time
from tools import DEFAULT_SERVER_DATE_FORMAT, DEFAULT_SERVER_DATETIME_FORMAT
from tools import DEFAULT_SERVER_DATETIME_FORMAT
import netsvc
from tools.translate import _
class claim_make_picking(osv.osv_memory):
class claim_make_picking(orm.TransientModel):
_name='claim_make_picking.wizard'
_description='Wizard to create pickings from claim lines'
_columns = {
'claim_line_source_location' : fields.many2one('stock.location', 'Source Location',help="Location where the returned products are from.", required=True),
'claim_line_dest_location' : fields.many2one('stock.location', 'Dest. Location',help="Location where the system will stock the returned products.", required=True),
'claim_line_ids' : fields.many2many('claim.line', 'claim_line_picking', 'claim_picking_id', 'claim_line_id', 'Claim lines'),
'claim_line_source_location' : fields.many2one('stock.location',
'Source Location',
help="Location where the "
"returned products are from.",
required=True),
'claim_line_dest_location' : fields.many2one('stock.location',
'Dest. Location',
help="Location where the system "
"will stock the returned products.",
required=True),
'claim_line_ids' : fields.many2many('claim.line', 'claim_line_picking',
'claim_picking_id', 'claim_line_id',
'Claim lines'),
}
def _get_claim_lines(self, cr, uid, context):
@@ -46,12 +56,15 @@ class claim_make_picking(osv.osv_memory):
elif context.get('picking_type') == 'out':
move_field = 'move_out_id'
good_lines = []
line_ids = line_obj.search(cr, uid, [('claim_id', '=', context['active_id'])], context=context)
line_ids = line_obj.search(cr, uid,
[('claim_id', '=', context['active_id'])],
context=context)
for line in line_obj.browse(cr, uid, line_ids, context=context):
if not line[move_field] or line[move_field].state == 'cancel':
good_lines.append(line.id)
if not good_lines:
raise osv.except_osv(_('Error !'), _('A picking has already been created for this claim !'))
raise osv.except_osv(_('Error !'),
_('A picking has already been created for this claim !'))
return good_lines
# Get default source location
@@ -60,11 +73,17 @@ class claim_make_picking(osv.osv_memory):
warehouse_obj = self.pool.get('stock.warehouse')
warehouse_id = context.get('warehouse_id')
if context.get('picking_type') == 'out':
loc_id = warehouse_obj.read(cr, uid, warehouse_id, ['lot_stock_id'], context=context)['lot_stock_id'][0]
loc_id = warehouse_obj.read(cr, uid, warehouse_id,
['lot_stock_id'],
context=context)['lot_stock_id'][0]
elif context.get('picking_type') in ['in', 'loss'] and context.get('partner_id'):
loc_id = self.pool.get('res.partner').read(cr, uid, context['partner_id'],
['property_stock_customer'],
context=context)['property_stock_customer']
if context.get('claim_type') and context['claim_type'] in ['customer', 'other'] or not context.get('claim_type'):
stock_property = 'property_stock_customer'
elif context.get('claim_type') and context['claim_type'] == 'supplier':
stock_property = 'property_stock_supplier'
loc_id = self.pool.get('res.partner').read(cr, uid,
context['partner_id'], [stock_property],
context=context)[stock_property]
return loc_id
# Get default destination location
@@ -72,12 +91,23 @@ class claim_make_picking(osv.osv_memory):
if context is None: context = {}
warehouse_obj = self.pool.get('stock.warehouse')
warehouse_id = context.get('warehouse_id')
if context.get('picking_type') == 'out':
loc_id = self.pool.get('res.partner').read(cr, uid, context.get('partner_id'), ['property_stock_customer'], context=context)['property_stock_customer'][0]
if context.get('picking_type') == 'out' and context.get('partner_id'):
if context.get('claim_type') and context['claim_type'] in ['customer', 'other'] or not context.get('claim_type'):
loc_id = warehouse_obj.read(cr, uid, warehouse_id,
['lot_output_id'],
context=context)['lot_output_id'][0]
elif context.get('claim_type') and context['claim_type'] == 'supplier':
stock_property = 'property_stock_supplier'
loc_id = self.pool.get('res.partner').read(cr, uid, context.get('partner_id'),
['property_stock_supplier'],
context=context)['property_stock_supplier'][0]
elif context.get('picking_type') == 'in':
loc_id = warehouse_obj.read(cr, uid, warehouse_id, ['lot_rma_id'], context=context)['lot_rma_id'][0]
loc_id = warehouse_obj.read(cr, uid, warehouse_id, ['lot_rma_id'],
context=context)['lot_rma_id'][0]
elif context.get('picking_type') == 'loss':
loc_id = warehouse_obj.read(cr, uid, warehouse_id, ['lot_carrier_loss_id'], context=context)['lot_carrier_loss_id'][0]
loc_id = warehouse_obj.read(cr, uid, warehouse_id,
['lot_carrier_loss_id'],
context=context)['lot_carrier_loss_id'][0]
return loc_id
_defaults = {
@@ -121,7 +151,9 @@ class claim_make_picking(osv.osv_memory):
('name', '=', view_name)
], context=context)[0]
wizard = self.browse(cr, uid, ids[0], context=context)
claim = self.pool.get('crm.claim').browse(cr, uid, context['active_id'], context=context)
claim = self.pool.get('crm.claim').browse(cr, uid,
context['active_id'],
context=context)
partner_id = claim.partner_id.id
# create picking
picking_id = picking_obj.create(cr, uid, {
@@ -141,8 +173,10 @@ class claim_make_picking(osv.osv_memory):
})
# Create picking lines
for wizard_claim_line in wizard.claim_line_ids:
#TOFIX # Motif : crm id ? stock_picking_id ?
name = wizard_claim_line.product_id.name or 'name'
move_id = self.pool.get('stock.move').create(cr, uid, {
'name' : wizard_claim_line.product_id.name_template, # Motif : crm id ? stock_picking_id ?
'name' : name,
'priority': '0',
#'create_date':
'date': time.strftime(DEFAULT_SERVER_DATETIME_FORMAT),
@@ -162,7 +196,9 @@ class claim_make_picking(osv.osv_memory):
'location_dest_id': wizard.claim_line_dest_location.id,
'note': note,
})
self.pool.get('claim.line').write(cr, uid, wizard_claim_line.id, {write_field: move_id}, context=context)
self.pool.get('claim.line').write(cr, uid, wizard_claim_line.id,
{write_field: move_id},
context=context)
wf_service = netsvc.LocalService("workflow")
if picking_id:
wf_service.trg_validate(uid, 'stock.picking', picking_id,'button_confirm', cr)

View File

@@ -21,30 +21,47 @@
#along with this program. If not, see <http://www.gnu.org/licenses/>. #
#########################################################################
from osv import fields, osv
from openerp.osv import fields, orm
import time
from tools import DEFAULT_SERVER_DATE_FORMAT, DEFAULT_SERVER_DATETIME_FORMAT
from tools import DEFAULT_SERVER_DATETIME_FORMAT
import netsvc
class claim_make_picking_from_picking(osv.osv_memory):
class claim_make_picking_from_picking(orm.TransientModel):
_name='claim_make_picking_from_picking.wizard'
_description='Wizard to create pickings from picking lines'
_columns = {
'picking_line_source_location' : fields.many2one('stock.location', 'Source Location',help="Location where the returned products are from.", required=True),
'picking_line_dest_location' : fields.many2one('stock.location', 'Dest. Location',help="Location where the system will stock the returned products.", required=True),
'picking_line_ids' : fields.many2many('stock.move', 'claim_picking_line_picking', 'claim_picking_id', 'picking_line_id', 'Picking lines'),
'picking_line_source_location' : fields.many2one('stock.location',
'Source Location',
help="Location where the "
"returned products are from.",
required=True),
'picking_line_dest_location' : fields.many2one('stock.location',
'Dest. Location',
help="Location where the "
"system will stock the "
"returned products.",
required=True),
'picking_line_ids' : fields.many2many('stock.move',
'claim_picking_line_picking',
'claim_picking_id',
'picking_line_id', 'Picking lines'),
}
def _get_picking_lines(self, cr, uid, context):
return self.pool.get('stock.picking').read(cr, uid, context['active_id'], ['move_lines'], context=context)['move_lines']
return self.pool.get('stock.picking').read(cr, uid,
context['active_id'],
['move_lines'],
context=context)['move_lines']
# Get default source location
def _get_source_loc(self, cr, uid, context):
if context is None: context = {}
warehouse_obj = self.pool.get('stock.warehouse')
warehouse_id = context.get('warehouse_id')
return warehouse_obj.read(cr, uid, warehouse_id, ['lot_rma_id'], context=context)['lot_rma_id'][0]
return warehouse_obj.read(cr, uid, warehouse_id, ['lot_rma_id'],
context=context)['lot_rma_id'][0]
# Get default destination location
def _get_dest_loc(self, cr, uid, context):
@@ -54,7 +71,8 @@ class claim_make_picking_from_picking(osv.osv_memory):
if context.get('picking_type'):
context_loc = context.get('picking_type')[8:]
loc_field = 'lot_%s_id' %context.get('picking_type')[8:]
loc_id = warehouse_obj.read(cr, uid, warehouse_id, [loc_field], context=context)[loc_field][0]
loc_id = warehouse_obj.read(cr, uid, warehouse_id,
[loc_field], context=context)[loc_field][0]
return loc_id
_defaults = {
@@ -104,7 +122,7 @@ class claim_make_picking_from_picking(osv.osv_memory):
# Create picking lines
for wizard_picking_line in wizard.picking_line_ids:
move_id = move_obj.create(cr, uid, {
'name' : wizard_picking_line.product_id.name_template, # Motif : crm id ? stock_picking_id ?
'name' : wizard_picking_line.product_id.name, # Motif : crm id ? stock_picking_id ?
'priority': '0',
#'create_date':
'date': time.strftime(DEFAULT_SERVER_DATETIME_FORMAT),
@@ -124,16 +142,19 @@ class claim_make_picking_from_picking(osv.osv_memory):
'location_dest_id': wizard.picking_line_dest_location.id,
'note': note,
})
wizard_move = move_obj.write(cr, uid, wizard_picking_line.id, {'move_dest_id': move_id}, context=context)
wizard_move = move_obj.write(cr, uid, wizard_picking_line.id,
{'move_dest_id': move_id},
context=context)
wf_service = netsvc.LocalService("workflow")
if picking_id:
wf_service.trg_validate(uid, 'stock.picking', picking_id,'button_confirm', cr)
wf_service.trg_validate(uid, 'stock.picking',
picking_id,'button_confirm', cr)
picking_obj.action_assign(cr, uid, [picking_id])
return {
'name': '%s' % name,
'view_type': 'form',
'view_mode': 'form',
'view_id': view_id,
'view_id': [view_id],
'domain' : "[('type', '=', '%s'),('partner_id','=',%s)]" % (p_type, partner_id),
'res_model': 'stock.picking',
'res_id': picking_id,

View File

@@ -19,8 +19,11 @@
<separator string="Select lines for picking" colspan="4"/>
<field name="picking_line_ids" nolabel="1" colspan="4"/>
<group col="4" colspan="2">
<button special="cancel" string="Cancel" name="action_cancel" type="object" icon='gtk-cancel'/>
<button name="action_create_picking_from_picking" string="Create picking"
<button special="cancel" string="Cancel"
name="action_cancel" type="object"
icon='gtk-cancel'/>
<button name="action_create_picking_from_picking"
string="Validate"
icon='gtk-ok' type="object"/>
</group>
</form>

View File

@@ -12,15 +12,20 @@
<field name="model">claim_make_picking.wizard</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Select exchange lines to add in picking">
<form string="Select exchange lines to treat (don't modify them, do it in the picking)">
<separator string="Locations" colspan="4"/>
<field name="claim_line_source_location" nolabel="1" />
<field name="claim_line_dest_location" nolabel="1" />
<separator string="Select lines for picking" colspan="4"/>
<field name="claim_line_ids" nolabel="1" colspan="4"/>
<separator string="Select exchange lines to treat (don't modify them, do it in the picking)" colspan="4"/>
<field name="claim_line_ids" nolabel="1" colspan="4"
domain="[('claim_id', '=', context.get('claim_id'))]"/>
<group col="4" colspan="2">
<button special="cancel" string="Cancel" name="action_cancel" type="object" icon='gtk-cancel'/>
<button name="action_create_picking" string="Create picking"
<button special="cancel" string="Cancel"
name="action_cancel"
type="object"
icon='gtk-cancel'/>
<button name="action_create_picking"
string="Validate"
icon='gtk-ok' type="object"/>
</group>
</form>

View File

@@ -1,105 +0,0 @@
# -*- coding: utf-8 -*-
#########################################################################
# #
# #
#########################################################################
# #
# Copyright (C) 2009-2011 Akretion, Emmanuel Samyn #
# #
#This program is free software: you can redistribute it and/or modify #
#it under the terms of the GNU General Public License as published by #
#the Free Software Foundation, either version 3 of the License, or #
#(at your option) any later version. #
# #
#This program is distributed in the hope that it will be useful, #
#but WITHOUT ANY WARRANTY; without even the implied warranty of #
#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
#GNU General Public License for more details. #
# #
#You should have received a copy of the GNU General Public License #
#along with this program. If not, see <http://www.gnu.org/licenses/>. #
#########################################################################
from osv import fields, osv
import pooler
import time
# Class to create a picking in from selected return lines
class exchange_from_returned_lines(osv.osv_memory):
_name='exchange_from_returned_lines.wizard'
_description='Wizard to create an exchange from selected return lines'
_columns = {
'exchange_line_ids' : fields.many2many('temp.exchange.line', string='Selected exchange lines'),
}
# Get selected lines to add to exchange
def _get_selected_lines(self, cr, uid,context):
returned_line_ids = self.pool.get('crm.claim').read(cr, uid, context['active_id'], ['return_line_ids'])['return_line_ids']
returned_lines = self.pool.get('return.line').browse(cr, uid,returned_line_ids)
M2M = []
for line in returned_lines:
if True: # ADD ALL LINE line.selected:
M2M.append(self.pool.get('temp.exchange.line').create(cr, uid, {
'name' : "none",
'returned_product_id' : line.product_id.id,
'returned_product_quantity' : line.product_returned_quantity,
'returned_prodlot_id' : line.prodlot_id.id,
'returned_unit_sale_price' : line.unit_sale_price,
'replacement_product_id': line.product_id.id,
'replacement_product_quantity' : line.product_returned_quantity,
}))
return M2M
_defaults = {
'exchange_line_ids': _get_selected_lines,
}
# If "Cancel" button pressed
def action_cancel(self,cr,uid,ids,conect=None):
return {'type': 'ir.actions.act_window_close',}
# If "Create" button pressed
def action_create_exchange(self, cr, uid, ids, context=None):
for exchange in self.browse(cr, uid,ids):
claim_id = self.pool.get('crm.claim').browse(cr, uid, context['active_id'])
# create exchange
for line in exchange.exchange_line_ids:
exchange_id = self.pool.get('product.exchange').create(cr, uid, {
'name' : "#",
'state': 'draft',
'exchange_send_date': time.strftime('%Y-%m-%d %H:%M:%S'),
'returned_product' : line.returned_product_id.id,
'returned_product_serial' : line.returned_prodlot_id.id,
'returned_product_qty' : line.returned_product_quantity,
'returned_unit_sale_price' : line.returned_unit_sale_price,
'replacement_product' : line.replacement_product_id.id,
'replacement_product_serial' : line.replacement_prodlot_id.id,
'replacement_product_qty' : line.replacement_product_quantity,
'claim_return_id' : claim_id.id
})
return {'type': 'ir.actions.act_window_close',}
exchange_from_returned_lines()
#===== Temp exchange line
class temp_exchange_line(osv.osv_memory):
"""
Class to handle a product exchange line
"""
_name = "temp.exchange.line"
_description = "List of product to exchange"
_columns = {
'name': fields.char('Comment', size=128, help="To describe the line product problem"),
'returned_product_id': fields.many2one('product.product', 'Returned product', required=True),
'returned_product_quantity' : fields.float('Returned quantity', digits=(12,2), help="Quantity of product returned"),
'returned_unit_sale_price' : fields.float('Unit sale price', digits=(12,2),),
'returned_prodlot_id': fields.many2one('stock.production.lot', 'Returned serial/Lot'),
'replacement_product_id': fields.many2one('product.product', 'Replacement product', required=True),
'replacement_product_quantity' : fields.float('Replacement quantity', digits=(12,2), help="Replacement quantity"),
'replacement_prodlot_id': fields.many2one('stock.production.lot', 'Replacement serial/Lot'),
}
temp_exchange_line()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@@ -1,90 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
#########################################################################
# #
# #
#########################################################################
# #
# Copyright (C) 2009-2011 Akretion, Emmanuel Samyn #
# #
#This program is free software: you can redistribute it and/or modify #
#it under the terms of the GNU General Public License as published by #
#the Free Software Foundation, either version 3 of the License, or #
#(at your option) any later version. #
# #
#This program is distributed in the hope that it will be useful, #
#but WITHOUT ANY WARRANTY; without even the implied warranty of #
#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
#GNU General Public License for more details. #
# #
#You should have received a copy of the GNU General Public License #
#along with this program. If not, see <http://www.gnu.org/licenses/>. #
#########################################################################
-->
<openerp>
<data>
<!-- SELECTED RETURN LINES FOR EXCHANGE FORM VIEW -->
<record id="view_exchange_from_returned_lines_form" model="ir.ui.view">
<field name="name">exchange_from_returned_lines_wiew</field>
<field name="model">exchange_from_returned_lines.wizard</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Select return lines to add in picking">
<separator string="Select lines for picking. DON'T FORGET TO SELECT THE REPLACEMENT PRODUCT. " colspan="4"/>
<field name="exchange_line_ids" nolabel="1" colspan="4"/>
<group col="4" colspan="2">
<button special="cancel" string="Cancel" name="action_cancel" type="object" icon='gtk-cancel'/>
<button name="action_create_exchange" string="Create exchange" icon='gtk-ok' type="object"/>
</group>
</form>
</field>
</record>
<!-- SELECTED RETURN LINES FOR EXCHANGE ACTION -->
<record id="action_exchange_from_returned_lines" model="ir.actions.act_window">
<field name="name">action_exchange_from_returned_lines</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">exchange_from_returned_lines.wizard</field>
<field name="src_model">crm.claim</field>
<field name="view_type">form</field>
<field name="view_mode">form</field>
<field name="target">new</field>
<!-- field name="context">{'claim_id':claim_id}</field -->
</record>
<!-- TEMP EXCHANGE LINE VIEW -->
<record model="ir.ui.view" id="temp_exchange_line_form_view">
<field name="name">Temp exchange line Form</field>
<field name="model">temp.exchange.line</field>
<field name="arch" type="xml">
<form string="Temp product exchange">
<separator string="Returned product" colspan="2"/>
<separator string="Replacement product" colspan="2"/>
<field name="returned_product_id"/>
<field name="replacement_product_id"/>
<field name="returned_prodlot_id"/>
<field name="replacement_prodlot_id"/>
<field name="returned_product_quantity"/>
<field name="replacement_product_quantity"/>
</form>
</field>
</record>
<record model="ir.ui.view" id="temp_exchange_line_tree_view">
<field name="name">temp_exchange_line_Tree</field>
<field name="model">temp.exchange.line</field>
<field name="type">tree</field>
<field name="arch" type="xml">
<tree string="Confirm exchange lines">
<field name="returned_product_id"/>
<field name="returned_prodlot_id"/>
<field name="returned_product_quantity"/>
<field name="replacement_product_id"/>
<field name="replacement_prodlot_id"/>
<field name="replacement_product_quantity"/>
</tree>
</field>
</record>
</data>
</openerp>

View File

@@ -1,116 +0,0 @@
# -*- coding: utf-8 -*-
#########################################################################
# #
# #
#########################################################################
# #
# Copyright (C) 2009-2011 Akretion, Emmanuel Samyn #
# #
#This program is free software: you can redistribute it and/or modify #
#it under the terms of the GNU General Public License as published by #
#the Free Software Foundation, either version 3 of the License, or #
#(at your option) any later version. #
# #
#This program is distributed in the hope that it will be useful, #
#but WITHOUT ANY WARRANTY; without even the implied warranty of #
#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
#GNU General Public License for more details. #
# #
#You should have received a copy of the GNU General Public License #
#along with this program. If not, see <http://www.gnu.org/licenses/>. #
#########################################################################
from osv import fields, osv
import pooler
import time
# Class to create a picking out from selected exchange lines
class picking_out_from_exchange_lines(osv.osv_memory):
_name='picking_out_from_exchange_lines.wizard'
_description='Wizard to create a picking out from selected exchange lines'
_columns = {
'exchange_line_ids' : fields.many2many('temp.exchange.line', string='Selected exchange lines'),
}
# Get selected lines to add to picking in
def _get_selected_lines(self, cr, uid,context):
exchange_line_ids = self.pool.get('crm.claim').read(cr, uid, context['active_id'], ['product_exchange_ids'])['product_exchange_ids']
exchange_lines = self.pool.get('product.exchange').browse(cr, uid,exchange_line_ids)
M2M = []
for line in exchange_lines:
if True: #line.selected:
M2M.append(self.pool.get('temp.exchange.line').create(cr, uid, {
'name' : "#",
'returned_product_id' : line.returned_product.id,
'returned_product_quantity' : line.returned_product_qty,
'returned_prodlot_id' : line.returned_product_serial.id,
'replacement_product_id': line.replacement_product.id,
'replacement_product_quantity' : line.replacement_product_qty,
'replacement_prodlot_id': line.replacement_product_serial.id,
}))
return M2M
_defaults = {
'exchange_line_ids': _get_selected_lines,
}
# If "Cancel" button pressed
def action_cancel(self,cr,uid,ids,conect=None):
return {'type': 'ir.actions.act_window_close',}
# If "Create" button pressed
def action_create_picking(self, cr, uid, ids, context=None):
for exchange_lines in self.browse(cr, uid,ids):
claim_id = self.pool.get('crm.claim').browse(cr, uid, context['active_id'])
partner_id = claim_id.partner_id.id
# create picking
picking_id = self.pool.get('stock.picking').create(cr, uid, {
'origin': "RMA/"+`claim_id.id`,
'type': 'out',
'move_type': 'one', # direct
'state': 'draft',
'date': time.strftime('%Y-%m-%d %H:%M:%S'),
'address_id': claim_id.partner_address_id.id,
'invoice_state': "none",
'company_id': claim_id.company_id.id,
# 'stock_journal_id': fields.many2one('stock.journal','Stock Journal', select=True),
'location_id': self.pool.get('stock.warehouse').read(cr, uid, [1],['lot_input_id'])[0]['lot_input_id'][0],
'location_dest_id': claim_id.partner_id.property_stock_customer.id,
'note' : 'RMA picking in',
})
# Create picking lines
for exchange_line in exchange_lines.exchange_line_ids:
move_id = self.pool.get('stock.move').create(cr, uid, {
'name' : exchange_line.replacement_product_id.name_template, # Motif : crm id ? stock_picking_id ?
'priority': '0',
#'create_date':
'date': time.strftime('%Y-%m-%d %H:%M:%S'),
'date_expected': time.strftime('%Y-%m-%d %H:%M:%S'),
'product_id': exchange_line.replacement_product_id.id,
'product_qty': exchange_line.replacement_product_quantity,
'product_uom': exchange_line.replacement_product_id.uom_id.id,
'address_id': claim_id.partner_address_id.id,
'prodlot_id': exchange_line.replacement_prodlot_id,
# 'tracking_id':
'picking_id': picking_id,
'state': 'draft',
# 'price_unit': 1.0, # to get from invoice line
# 'price_currency_id': claim_id.company_id.currency_id.id, # from invoice ???
'company_id': claim_id.company_id.id,
'location_id': self.pool.get('stock.warehouse').read(cr, uid, [1],['lot_input_id'])[0]['lot_input_id'][0],
'location_dest_id': claim_id.partner_id.property_stock_customer.id,
'note': 'RMA Refound',
})
view = {
'name': 'Customer Picking OUT',
'view_type': 'form',
'view_mode': 'tree,form',
'domain' : "[('type', '=', 'out'),('partner_id','=',%s)]"%partner_id,
'res_model': 'stock.picking',
'type': 'ir.actions.act_window',
}
return view
picking_out_from_exchange_lines()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@@ -1,57 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
#########################################################################
# #
# #
#########################################################################
# #
# Copyright (C) 2009-2011 Akretion, Emmanuel Samyn #
# #
#This program is free software: you can redistribute it and/or modify #
#it under the terms of the GNU General Public License as published by #
#the Free Software Foundation, either version 3 of the License, or #
#(at your option) any later version. #
# #
#This program is distributed in the hope that it will be useful, #
#but WITHOUT ANY WARRANTY; without even the implied warranty of #
#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
#GNU General Public License for more details. #
# #
#You should have received a copy of the GNU General Public License #
#along with this program. If not, see <http://www.gnu.org/licenses/>. #
#########################################################################
-->
<openerp>
<data>
<!-- SELECTED exchange LINES FOR PICKING OUT FORM VIEW -->
<record id="view_picking_out_from_exchange_lines_form" model="ir.ui.view">
<field name="name">picking_out_from_exchange_lines_wiew</field>
<field name="model">picking_out_from_exchange_lines.wizard</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Select exchange lines to add in picking">
<separator string="Select lines for picking out " colspan="4"/>
<field name="exchange_line_ids" nolabel="1" colspan="4"/>
<group col="4" colspan="2">
<button special="cancel" string="Cancel" name="action_cancel" type="object" icon='gtk-cancel'/>
<button name="action_create_picking" string="Create picking" icon='gtk-ok' type="object"/>
</group>
</form>
</field>
</record>
<!-- SELECTED exchange LINES FOR PICKING OUT ACTION -->
<record id="action_picking_out_from_exchange_lines" model="ir.actions.act_window">
<field name="name">action_picking_out_from_exchange_lines</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">picking_out_from_exchange_lines.wizard</field>
<field name="src_model">crm.claim</field>
<field name="view_type">form</field>
<field name="view_mode">form</field>
<field name="target">new</field>
<!-- field name="context">{'claim_id':claim_id}</field -->
</record>
</data>
</openerp>

View File

@@ -1,227 +0,0 @@
# -*- coding: utf-8 -*-
#########################################################################
# #
# #
#########################################################################
# #
# Copyright (C) 2009-2011 Akretion, Emmanuel Samyn #
# #
#This program is free software: you can redistribute it and/or modify #
#it under the terms of the GNU General Public License as published by #
#the Free Software Foundation, either version 3 of the License, or #
#(at your option) any later version. #
# #
#This program is distributed in the hope that it will be useful, #
#but WITHOUT ANY WARRANTY; without even the implied warranty of #
#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
#GNU General Public License for more details. #
# #
#You should have received a copy of the GNU General Public License #
#along with this program. If not, see <http://www.gnu.org/licenses/>. #
#########################################################################
from osv import fields, osv
import pooler
import time
# Class to create a picking in from selected return lines
class picking_in_from_returned_lines(osv.osv_memory):
_name='picking_in_from_returned_lines.wizard'
_description='Wizard to create a picking in from selected return lines'
_columns = {
'claim_line_location' : fields.many2one('stock.location', 'Dest. Location',help="Location where the system will stock the returned products.", select=True),
'claim_line_ids' : fields.many2many('temp.claim.line',string='Selected return lines'),
}
# Get selected lines to add to picking in
def _get_selected_lines(self, cr, uid,context):
returned_line_ids = self.pool.get('crm.claim').read(cr, uid, context['active_id'], ['claim_line_ids'])['claim_line_ids']
returned_lines = self.pool.get('claim.line').browse(cr, uid,returned_line_ids)
M2M = []
for line in returned_lines:
if True: #line.selected:
M2M.append(self.pool.get('temp.claim.line').create(cr, uid, {
'claim_origine' : "none",
'invoice_id' : line.invoice_id.id,
'product_id' : line.product_id.id,
'product_returned_quantity' : line.product_returned_quantity,
'prodlot_id' : line.prodlot_id.id,
'price_unit' : line.unit_sale_price,
}))
return M2M
# Get default destination location
def _get_dest_loc(self, cr, uid,context):
return self.pool.get('stock.warehouse').read(cr, uid, [1],['lot_input_id'])[0]['lot_input_id'][0]
_defaults = {
'claim_line_ids': _get_selected_lines,
'claim_line_location' : _get_dest_loc,
}
# If "Cancel" button pressed
def action_cancel(self,cr,uid,ids,conect=None):
return {'type': 'ir.actions.act_window_close',}
# If "Create" button pressed
def action_create_picking(self, cr, uid, ids, context=None):
print "context", context
partner_id = 0
# wf_service = netsvc.LocalService("workflow")
for picking in self.browse(cr, uid,ids):
claim_id = self.pool.get('crm.claim').browse(cr, uid, context['active_id'])
partner_id = claim_id.partner_id.id
# location type
location = -1
if claim_id.claim_type == "customer":
location = claim_id.partner_id.property_stock_customer.id
else:
location = claim_id.partner_id.property_stock_supplier.id
# create picking
picking_id = self.pool.get('stock.picking').create(cr, uid, {
'origin': claim_id.sequence,
'type': 'in',
'move_type': 'one', # direct
'state': 'draft',
'date': time.strftime('%Y-%m-%d %H:%M:%S'),
'address_id': claim_id.partner_address_id.id,
'invoice_state': "none",
'company_id': claim_id.company_id.id,
'location_id': location,
'location_dest_id': picking.claim_line_location.id,
'note' : 'RMA picking in',
'claim_id': claim_id.id,
})
# Create picking lines
for picking_line in picking.claim_line_ids:
move_id = self.pool.get('stock.move').create(cr, uid, {
'name' : picking_line.product_id.name_template, # Motif : crm id ? stock_picking_id ?
'priority': '0',
#'create_date':
'date': time.strftime('%Y-%m-%d %H:%M:%S'),
'date_expected': time.strftime('%Y-%m-%d %H:%M:%S'),
'product_id': picking_line.product_id.id,
'product_qty': picking_line.product_returned_quantity,
'product_uom': picking_line.product_id.uom_id.id,
'address_id': claim_id.partner_address_id.id,
'prodlot_id': picking_line.prodlot_id.id,
# 'tracking_id':
'picking_id': picking_id,
'state': 'draft',
'price_unit': picking_line.price_unit,
# 'price_currency_id': claim_id.company_id.currency_id.id, # from invoice ???
'company_id': claim_id.company_id.id,
'location_id': location,
'location_dest_id': picking.claim_line_location.id,
#self.pool.get('stock.warehouse').read(cr, uid, [1],['lot_input_id'])[0]['lot_input_id'][0],
'note': 'RMA Refound',
})
return {
'name': 'Customer Picking IN',
'view_type': 'form',
'view_mode': 'tree,form',
'domain' : "[('type', '=', 'in'),('partner_id','=',%s)]"%partner_id,
'res_model': 'stock.picking',
'type': 'ir.actions.act_window',
}
picking_in_from_returned_lines()
# Class to create a picking out from selected return lines
class picking_out_from_returned_lines(osv.osv_memory):
_name='picking_out_from_returned_lines.wizard'
_description='Wizard to create a picking out from selected return lines'
_columns = {
'claim_line_ids' : fields.many2many('temp.claim.line', string='Selected return lines'),
}
# Get selected lines to add to picking in
def _get_selected_lines(self, cr, uid,context):
returned_line_ids = self.pool.get('crm.claim').read(cr, uid, context['active_id'], ['claim_line_ids'])['claim_line_ids']
returned_lines = self.pool.get('claim.line').browse(cr, uid,returned_line_ids)
M2M = []
for line in returned_lines:
if True: # line.selected:
M2M.append(self.pool.get('temp.claim.line').create(cr, uid, {
'claim_origine' : "none",
'invoice_id' : line.invoice_line_id.invoice_id.id,
'product_id' : line.product_id.id,
'product_returned_quantity' : line.product_returned_quantity,
'prodlot_id' : line.prodlot_id.id,
'price_unit' : line.unit_sale_price,
}))
return M2M
_defaults = {
'claim_line_ids': _get_selected_lines,
}
# If "Cancel" button pressed
def action_cancel(self,cr,uid,ids,context=None):
return {'type': 'ir.actions.act_window_close',}
# If "Create" button pressed
def action_create_picking(self, cr, uid, ids, context=None):
partner_id = 0
for picking in self.browse(cr, uid,ids):
claim_id = self.pool.get('crm.claim').browse(cr, uid, context['active_id'])
partner_id = claim_id.partner_id.id
# location type
location = -1
if claim_id.claim_type == "customer":
location = claim_id.partner_id.property_stock_customer.id
else:
location = claim_id.partner_id.property_stock_supplier.id
# create picking
picking_id = self.pool.get('stock.picking').create(cr, uid, {
'origin': claim_id.sequence,
'type': 'out',
'move_type': 'one', # direct
'state': 'draft',
'date': time.strftime('%Y-%m-%d %H:%M:%S'),
'address_id': claim_id.partner_address_id.id,
'invoice_state': "none",
'company_id': claim_id.company_id.id,
# 'stock_journal_id': fields.many2one('stock.journal','Stock Journal', select=True),
'location_id': self.pool.get('stock.warehouse').read(cr, uid, [1],['lot_input_id'])[0]['lot_input_id'][0],
'location_dest_id': location,
'note' : 'RMA picking in',
})
# Create picking lines
for picking_line in picking.claim_line_ids:
move_id = self.pool.get('stock.move').create(cr, uid, {
'name' : picking_line.product_id.name_template, # Motif : crm id ? stock_picking_id ?
'priority': '0',
#'create_date':
'date': time.strftime('%Y-%m-%d %H:%M:%S'),
'date_expected': time.strftime('%Y-%m-%d %H:%M:%S'),
'product_id': picking_line.product_id.id,
'product_qty': picking_line.product_returned_quantity,
'product_uom': picking_line.product_id.uom_id.id,
'address_id': claim_id.partner_address_id.id,
'prodlot_id': picking_line.prodlot_id.id,
# 'tracking_id':
'picking_id': picking_id,
'state': 'draft',
'price_unit': picking_line.price_unit,
# 'price_currency_id': claim_id.company_id.currency_id.id, # from invoice ???
'company_id': claim_id.company_id.id,
'location_id': self.pool.get('stock.warehouse').read(cr, uid, [1],['lot_input_id'])[0]['lot_input_id'][0],
'location_dest_id': location,
'note': 'RMA Refound',
})
return {
'name': 'Customer Picking OUT',
'view_type': 'form',
'view_mode': 'tree,form',
'domain' : "[('type', '=', 'out'),('partner_id','=',%s)]"%partner_id,
'res_model': 'stock.picking',
'type': 'ir.actions.act_window',
}
picking_out_from_returned_lines()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@@ -1,89 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
#########################################################################
# #
# #
#########################################################################
# #
# Copyright (C) 2009-2011 Akretion, Emmanuel Samyn #
# #
#This program is free software: you can redistribute it and/or modify #
#it under the terms of the GNU General Public License as published by #
#the Free Software Foundation, either version 3 of the License, or #
#(at your option) any later version. #
# #
#This program is distributed in the hope that it will be useful, #
#but WITHOUT ANY WARRANTY; without even the implied warranty of #
#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
#GNU General Public License for more details. #
# #
#You should have received a copy of the GNU General Public License #
#along with this program. If not, see <http://www.gnu.org/licenses/>. #
#########################################################################
-->
<openerp>
<data>
<!-- SELECTED RETURN LINES FOR PICKING IN FORM VIEW -->
<record id="view_picking_in_from_returned_lines_form" model="ir.ui.view">
<field name="name">picking_in_from_returned_lines_wiew</field>
<field name="model">picking_in_from_returned_lines.wizard</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Select return lines to add in picking">
<separator string="Destination location" colspan="4"/>
<field name="claim_line_location" nolabel="1" /> <!-- domain="[('usage','=','internal')]" -->
<separator string="Select lines for picking " colspan="4"/>
<field name="claim_line_ids" nolabel="1" colspan="4"/>
<group col="4" colspan="2">
<button special="cancel" string="Cancel" name="action_cancel" type="object" icon='gtk-cancel'/>
<button name="action_create_picking" string="Create picking" icon='gtk-ok' type="object"/>
</group>
</form>
</field>
</record>
<!-- SELECTED RETURN LINES FOR PICKING IN ACTION -->
<record id="action_picking_in_from_returned_lines" model="ir.actions.act_window">
<field name="name">action_picking_in_from_returned_lines</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">picking_in_from_returned_lines.wizard</field>
<field name="src_model">crm.claim</field>
<field name="view_type">form</field>
<field name="view_mode">form</field>
<field name="target">new</field>
<!-- field name="domain">['claim_id','=',claim_id}</field
<field name="context">{'claim_id':claim_id}</field> -->
</record>
<!-- SELECTED RETURN LINES FOR PICKING OUT FORM VIEW -->
<record id="view_picking_out_from_returned_lines_form" model="ir.ui.view">
<field name="name">picking_out_from_returned_lines_wiew</field>
<field name="model">picking_out_from_returned_lines.wizard</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Select return lines to add in picking">
<separator string="Select lines for picking out " colspan="4"/>
<field name="claim_line_ids" nolabel="1" colspan="4"/>
<group col="4" colspan="2">
<button special="cancel" string="Cancel" name="action_cancel" type="object" icon='gtk-cancel'/>
<button name="action_create_picking" string="Create picking" icon='gtk-ok' type="object"/>
</group>
</form>
</field>
</record>
<!-- SELECTED RETURN LINES FOR PICKING OUT ACTION -->
<record id="action_picking_out_from_returned_lines" model="ir.actions.act_window">
<field name="name">action_picking_out_from_returned_lines</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">picking_out_from_returned_lines.wizard</field>
<field name="src_model">crm.claim</field>
<field name="view_type">form</field>
<field name="view_mode">form</field>
<field name="target">new</field>
<!-- <field name="context">{'claim_id':claim_id}</field> -->
</record>
</data>
</openerp>

View File

@@ -1,129 +0,0 @@
# -*- coding: utf-8 -*-
#########################################################################
# #
# #
#########################################################################
# #
# Copyright (C) 2009-2011 Akretion, Emmanuel Samyn #
# #
#This program is free software: you can redistribute it and/or modify #
#it under the terms of the GNU General Public License as published by #
#the Free Software Foundation, either version 3 of the License, or #
#(at your option) any later version. #
# #
#This program is distributed in the hope that it will be useful, #
#but WITHOUT ANY WARRANTY; without even the implied warranty of #
#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
#GNU General Public License for more details. #
# #
#You should have received a copy of the GNU General Public License #
#along with this program. If not, see <http://www.gnu.org/licenses/>. #
#########################################################################
from osv import fields, osv
import pooler
import time
class refund_from_returned_lines(osv.osv_memory):
_name='refund_from_returned_lines.wizard'
_description='Wizard to create an refund for selected product return lines'
_columns = {
'refund_journal' : fields.many2one('account.journal', 'Refund journal', select=True),
'claim_line_ids' : fields.many2many('temp.claim.line', string='Selected return lines'),
}
# Get selected lines to add to picking in
def _get_selected_lines(self, cr, uid,context):
returned_line_ids = self.pool.get('crm.claim').read(cr, uid, context['active_id'], ['claim_line_ids'])['claim_line_ids']
returned_lines = self.pool.get('claim.line').browse(cr, uid,returned_line_ids)
M2M = []
for line in returned_lines:
if True: #line.selected:
M2M.append(self.pool.get('temp.claim.line').create(cr, uid, {
'claim_origine' : "none",
'invoice_id' : line.invoice_id.id,
'product_id' : line.product_id.id,
'product_returned_quantity' : line.product_returned_quantity,
'prodlot_id' : line.prodlot_id.id,
'price_unit' : line.unit_sale_price,
}))
return M2M
# Get default journal
def _get_journal(self, cr, uid,context):
#('company_id','=',claim_id.company_id.id)
# ,('refund_journal','=','True')
return self.pool.get('account.journal').search(cr, uid, [('type','=','sale_refund')],limit=1)[0]
_defaults = {
'claim_line_ids': _get_selected_lines,
'refund_journal' : _get_journal,
}
# On "Cancel" button
def action_cancel(self,cr,uid,ids,context=None):
return {'type': 'ir.actions.act_window_close',}
# On "Create" button
def action_create_refund(self, cr, uid, ids, context=None):
partner_id = 0
for refund in self.browse(cr, uid,ids):
claim_id = self.pool.get('crm.claim').browse(cr, uid, context['active_id'])
partner_id = claim_id.partner_id.id
# invoice type
invoice_type = "out_refund"
if claim_id.claim_type == "supplier":
invoice_type = "in_refund"
# create invoice
invoice_id = self.pool.get('account.invoice').create(cr, uid, {
'claim_origine' : "none",
'origin' : claim_id.sequence,
'type' : invoice_type,
'state' : 'draft',
'partner_id' : claim_id.partner_id.id,
'user_id' : uid,
'reference_type': 'none',
'date_invoice': time.strftime('%Y-%m-%d %H:%M:%S'),
# 'date_due':
'address_contact_id' : claim_id.partner_address_id.id,
'address_invoice_id' : claim_id.partner_address_id.id,
'account_id' : claim_id.partner_id.property_account_receivable.id,
'currency_id' : claim_id.company_id.currency_id.id, # from invoice ???
'journal_id' : refund.refund_journal.id,
'company_id' : claim_id.company_id.id,
'comment' : 'RMA Refund',
'claim_id': claim_id.id,
})
# Create invoice lines
for refund_line in refund.claim_line_ids:
if refund_line.invoice_id:
invoice_line_id = self.pool.get('account.invoice.line').create(cr, uid, {
'name' : refund_line.product_id.name_template,
'origin' : claim_id.sequence,
'invoice_id' : invoice_id,
'uos_id' : refund_line.product_id.uom_id.id,
'product_id':refund_line.product_id.id,
'account_id': claim_id.partner_id.property_account_receivable.id, # refund_line.product_id.property_account_expense.id,
'price_unit':refund_line.price_unit,
'quantity': refund_line.product_returned_quantity,
# 'discount':
# 'invoice_line_tax_id':
# 'account_analytic_id':
'company_id' : claim_id.company_id.id,
'partner_id' : refund_line.invoice_id.partner_id.id,
'note': 'RMA Refund',
})
else:
raise osv.except_osv(_('Error !'), _('Cannot find any invoice for the return line!'))
return {
'name': 'Customer Refounds',
'view_type': 'form',
'view_mode': 'tree,form',
'domain' : "[('type', '=', '"+invoice_type+"'),('partner_id','=',"+str(partner_id)+")]",
'res_model': 'account.invoice',
'type': 'ir.actions.act_window',
}
refund_from_returned_lines()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@@ -1,67 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
#########################################################################
# #
# #
#########################################################################
# #
# Copyright (C) 2009-2011 Akretion, Emmanuel Samyn #
# #
#This program is free software: you can redistribute it and/or modify #
#it under the terms of the GNU General Public License as published by #
#the Free Software Foundation, either version 3 of the License, or #
#(at your option) any later version. #
# #
#This program is distributed in the hope that it will be useful, #
#but WITHOUT ANY WARRANTY; without even the implied warranty of #
#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
#GNU General Public License for more details. #
# #
#You should have received a copy of the GNU General Public License #
#along with this program. If not, see <http://www.gnu.org/licenses/>. #
#########################################################################
-->
<openerp>
<data>
<!-- SELECT FORM VIEW -->
<!-- <record id="view_refund_from_returned_lines_form" model="ir.ui.view">-->
<!-- <field name="name">refund_from_returned_lines_wiew</field>-->
<!-- <field name="model">refund_from_returned_lines.wizard</field>-->
<!-- <field name="type">form</field>-->
<!-- <field name="arch" type="xml">-->
<!-- <form string="Select return lines to refund">-->
<!-- <separator string="Select lines for picking " colspan="4"/>-->
<!-- <field name="refund_journal"/>-->
<!-- <field name="return_line_ids" nolabel="1" colspan="4"/>-->
<!-- <group col="4" colspan="2">-->
<!-- <button special="cancel" string="Cancel" name="action_cancel" type="object" icon='gtk-cancel'/>-->
<!-- <button name="action_create_refund" string="Create refund" icon='gtk-ok' type="object"/>-->
<!-- </group>-->
<!-- </form>-->
<!-- </field>-->
<!-- </record> -->
<!-- -->
<!-- SELECT ACTION -->
<!-- <record id="action_refund_from_returned_lines" model="ir.actions.act_window">-->
<!-- <field name="name">action_refund_from_returned_lines</field>-->
<!-- <field name="type">ir.actions.act_window</field>-->
<!-- <field name="res_model">refund_from_returned_lines.wizard</field>-->
<!-- <field name="src_model">crm.claim</field>-->
<!-- <field name="view_type">form</field>-->
<!-- <field name="view_mode">form</field>-->
<!-- <field name="target">new</field> -->
<!-- field name="context">{'claim_id':claim_id}</field -->
<!-- </record> -->
<!-- -->
<!-- <record id="action_claim_refund" model="ir.actions.act_window">-->
<!-- <field name="name">New Refund</field>-->
<!-- <field name="res_model">refund_from_returned_lines.wizard</field>-->
<!-- <field name="view_type">form</field>-->
<!-- <field name="view_mode">tree,form</field>-->
<!-- <field name="view_id" ref="account.view_account_invoice_refund"/>-->
<!-- <field name="target">new</field>-->
<!-- </record>-->
</data>
</openerp>

View File

@@ -1,180 +0,0 @@
# -*- coding: utf-8 -*-
#########################################################################
# #
# #
#########################################################################
# #
# Copyright (C) 2009-2011 Akretion, Emmanuel Samyn #
# #
#This program is free software: you can redistribute it and/or modify #
#it under the terms of the GNU General Public License as published by #
#the Free Software Foundation, either version 3 of the License, or #
#(at your option) any later version. #
# #
#This program is distributed in the hope that it will be useful, #
#but WITHOUT ANY WARRANTY; without even the implied warranty of #
#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
#GNU General Public License for more details. #
# #
#You should have received a copy of the GNU General Public License #
#along with this program. If not, see <http://www.gnu.org/licenses/>. #
#########################################################################
from osv import fields, osv
import pooler
#import time
#from datetime import datetime
#from dateutil.relativedelta import relativedelta
#===== WIZ STEP 1 : Invoice selection
class returned_lines_from_invoice_invoice(osv.osv_memory):
_name='returned_lines_from_invoice_invoice.wizard'
_description='Wizard to create product return lines from invoice'
_columns = {
'invoice_id': fields.many2one('account.invoice', 'Invoice', required=True),
'partner_id': fields.many2one('res.partner', 'Partner'),
}
# Get partner from case is set
def _get_default_partner_id(self, cr, uid, context):
return self.pool.get('crm.claim').read(cr, uid, context['active_id'], ['partner_id'])['partner_id']
_defaults = {
'partner_id': _get_default_partner_id,
}
# If "Cancel" button pressed
def action_cancel(self,cr,uid,ids,conect=None):
return {'type': 'ir.actions.act_window_close',}
# If "Return all" button pressed
def action_return_all(self, cr, uid, ids, context):
# Get invoice id
inv_id = 0
for wiz_obj in self.browse(cr,uid,ids):
inv_id = wiz_obj.invoice_id.id
# Get invoice line ids from invoice id
invoice_line_pool = self.pool.get('account.invoice.line')
invoice_lines_ids = invoice_line_pool.search(cr, uid, [('invoice_id', '=', inv_id)])
# Get invoice lines from invoice line ids
for invoice_line in invoice_line_pool.browse(cr,uid,invoice_lines_ids):
claim_line_pool = self.pool.get('claim.line')
line_id = claim_line_pool.create(cr, uid, {
'claim_origine' : "none",
'invoice_id' : invoice_line.invoice_id.id,
'product_id' : invoice_line.product_id.id,
'product_returned_quantity' : invoice_line.quantity,
'unit_sale_price' : invoice_line.price_unit,
#'prodlot_id' : invoice_line.,
'claim_id' : context['active_id'],
'selected' : False,
'state' : 'draft',
})
for line in claim_line_pool.browse(cr,uid,[line_id],context):
line.set_warranty()
return {'type': 'ir.actions.act_window_close',}
# If "Select lines" button pressed
def action_select_lines(self, cr, uid, ids, context):
# Add invoice_id to context
for wiz_obj in self.browse(cr,uid,ids):
context['invoice_id'] = wiz_obj.invoice_id.id
return {
'context': context,
'view_type': 'form',
'view_mode': 'form',
'res_model': 'returned_lines_from_invoice_line.wizard',
'view_id': False,
'type': 'ir.actions.act_window',
'target': 'new',
}
returned_lines_from_invoice_invoice()
#===== WIZ STEP 2 : line selection
class returned_lines_from_invoice_lines(osv.osv_memory):
_name='returned_lines_from_invoice_line.wizard'
_description='Wizard to create product return lines from invoice'
_columns = {
'claim_line_ids' : fields.many2many('temp.claim.line', string='claim lines'),
}
# Get possible returns from invoice
def _get_possible_returns_from_invoice(self, cr, uid, context):
# Get invoice lines from invoice
invoice_lines_ids = self.pool.get('account.invoice.line').search(cr, uid, [('invoice_id', '=', context['invoice_id'])])
M2M = []
# Create return lines from invoice lines
for invoice_line in self.pool.get('account.invoice.line').browse(cr,uid,invoice_lines_ids):
M2M.append(self.pool.get('temp.claim.line').create(cr, uid, {
'claim_origine' : "none",
'invoice_id' : invoice_line.invoice_id.id,
'invoice_line_id' : invoice_line.id,
'product_id' : invoice_line.product_id.id,
'product_returned_quantity' : invoice_line.quantity,
#'prodlot_id' : invoice_line.,
'price_unit': invoice_line.price_unit,
}))
return M2M
_defaults = {
'claim_line_ids': _get_possible_returns_from_invoice,
}
# If "Cancel" button pressed
def action_cancel(self,cr,uid,ids,conect=None):
return {'type': 'ir.actions.act_window_close',}
# If "Create" button pressed, for all temp return line create return line
def action_create_returns(self, cr, uid, ids, context=None):
for wiz_obj in self.browse(cr,uid,ids):
for line in wiz_obj.claim_line_ids:
claim_line_pool = self.pool.get('claim.line')
line_id = claim_line_pool.create(cr, uid, {
'claim_origine' : line.claim_origine,
'invoice_id' : line.invoice_id.id,
'product_id' : line.product_id.id,
'product_returned_quantity' : line.product_returned_quantity,
'unit_sale_price' : line.price_unit,
#'prodlot_id' : invoice_line.,
'claim_id' : context['active_id'],
'selected' : False,
'state' : 'draft',
})
for line in claim_line_pool.browse(cr,uid,[line_id],context):
line.set_warranty()
return {
'type': 'ir.actions.act_window_close',
}
returned_lines_from_invoice_lines()
#===== Temp returned line
class temp_claim_line(osv.osv_memory):
"""
Class to handle a product return line (corresponding to one invoice line)
"""
_name = "temp.claim.line"
_description = "List of product to return"
_columns = {
'claim_origine': fields.selection([('none','Not specified'),
('legal','Legal retractation'),
('cancellation','Order cancellation'),
('damaged','Damaged delivered product'),
('error','Shipping error'),
('exchange','Exchange request'),
('lost','Lost during transport'),
('other','Other')], 'Claim Subject', required=True, help="To describe the line product problem"),
'invoice_id': fields.many2one('account.invoice', 'Invoice'),
'invoice_line_id' : fields.many2one('account.invoice.line', 'Invoice line'),
'product_id': fields.many2one('product.product', 'Product'),
'product_returned_quantity' : fields.float('Returned quantity', digits=(12,2), help="Quantity of product returned"),
'prodlot_id': fields.many2one('stock.production.lot', 'Serial / Lot Number'),
'price_unit': fields.float('Unit sale price', digits=(12,2),),
}
temp_claim_line()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@@ -1,89 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
#########################################################################
# #
# #
#########################################################################
# #
# Copyright (C) 2009-2011 Akretion, Emmanuel Samyn #
# #
#This program is free software: you can redistribute it and/or modify #
#it under the terms of the GNU General Public License as published by #
#the Free Software Foundation, either version 3 of the License, or #
#(at your option) any later version. #
# #
#This program is distributed in the hope that it will be useful, #
#but WITHOUT ANY WARRANTY; without even the implied warranty of #
#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
#GNU General Public License for more details. #
# #
#You should have received a copy of the GNU General Public License #
#along with this program. If not, see <http://www.gnu.org/licenses/>. #
#########################################################################
-->
<openerp>
<data>
<!-- SELECT INVOICE FORM VIEW -->
<record id="view_create_return_invoice_form" model="ir.ui.view">
<field name="name">returned_lines_from_invoice_view</field>
<field name="model">returned_lines_from_invoice_invoice.wizard</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Select invoice">
<field name="invoice_id" domain="[('partner_id','=',partner_id)]"/>
<field name="partner_id"/>
<group col="4" colspan="2">
<button special="cancel" string="Cancel" name="action_cancel" type="object" icon='gtk-cancel'/>
<button name="action_return_all" string="Return all invoice lines" icon='gtk-ok' type="object"/>
<button name="action_select_lines" string="Select lines to return" icon='gtk-ok' type="object"/>
</group>
</form>
</field>
</record>
<!-- SELECT INVOICE ACTION -->
<record id="action_create_return_inv" model="ir.actions.act_window">
<field name="name">action_create_return_invoice</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">returned_lines_from_invoice_invoice.wizard</field>
<field name="src_model">crm.claim</field>
<field name="view_type">form</field>
<field name="view_mode">form</field>
<field name="target">new</field>
<field name="context">{}</field>
</record>
<!-- SELECT FORM VIEW -->
<record id="view_create_return_invoice_line_form" model="ir.ui.view">
<field name="name">returned_lines_from_invoice_line_wiew</field>
<field name="model">returned_lines_from_invoice_line.wizard</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Select return lines to create">
<separator string="Select return lines to create" colspan="4"/>
<field name="claim_line_ids" nolabel="1" colspan="4"/>
<group col="4" colspan="2">
<button special="cancel" string="Cancel" name="action_cancel" type="object" icon='gtk-cancel'/>
<button name="action_create_returns" string="Create selected returns" icon='gtk-ok' type="object"/>
</group>
</form>
</field>
</record>
<!-- SELECT TEMP RETURN LINES TREE VIEW -->
<record model="ir.ui.view" id="temp_claim_line_tree_view">
<field name="name">temp_claim_line_Tree</field>
<field name="model">temp.claim.line</field>
<field name="type">tree</field>
<field name="arch" type="xml">
<tree string="Confirm return lines">
<field name="invoice_id"/>
<field name="product_id"/>
<field name="prodlot_id"/>
<field name="product_returned_quantity"/>
</tree>
</field>
</record>
</data>
</openerp>