mirror of
https://github.com/OCA/rma.git
synced 2025-02-16 17:11:47 +02:00
[UPDATE] to openerp 6.1 version
This commit is contained in:
@@ -104,20 +104,23 @@ class return_line(osv.osv):
|
||||
|
||||
# Method to calculate warranty limit
|
||||
def set_warranty_limit(self, cr, uid, ids,context,return_line):
|
||||
warning = "Valid"
|
||||
if return_line.claim_id.claim_type == 'supplier':
|
||||
if return_line.prodlot_id :
|
||||
limit = (datetime.strptime(return_line.invoice_id.date_invoice, '%Y-%m-%d') + relativedelta(months=int(return_line.product_id.seller_ids[0].warranty_duration))).strftime('%Y-%m-%d') # TO BE IMPLEMENTED !!!
|
||||
if return_line.invoice_id.date_invoice:
|
||||
warning = "Valid"
|
||||
if return_line.claim_id.claim_type == 'supplier':
|
||||
if return_line.prodlot_id :
|
||||
limit = (datetime.strptime(return_line.invoice_id.date_invoice, '%Y-%m-%d') + relativedelta(months=int(return_line.product_id.seller_ids[0].warranty_duration))).strftime('%Y-%m-%d') # TO BE IMPLEMENTED !!!
|
||||
else :
|
||||
limit = (datetime.strptime(return_line.invoice_id.date_invoice, '%Y-%m-%d') + relativedelta(months=int(return_line.product_id.seller_ids[0].warranty_duration))).strftime('%Y-%m-%d')
|
||||
else :
|
||||
limit = (datetime.strptime(return_line.invoice_id.date_invoice, '%Y-%m-%d') + relativedelta(months=int(return_line.product_id.seller_ids[0].warranty_duration))).strftime('%Y-%m-%d')
|
||||
else :
|
||||
limit = (datetime.strptime(return_line.invoice_id.date_invoice, '%Y-%m-%d') + relativedelta(months=int(return_line.product_id.warranty))).strftime('%Y-%m-%d')
|
||||
if limit < return_line.claim_id.date:
|
||||
warning = 'Expired'
|
||||
self.write(cr,uid,ids,{
|
||||
limit = (datetime.strptime(return_line.invoice_id.date_invoice, '%Y-%m-%d') + relativedelta(months=int(return_line.product_id.warranty))).strftime('%Y-%m-%d')
|
||||
if limit < return_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 !'))
|
||||
return True
|
||||
|
||||
# Method to return the partner delivery address or if none, the default address
|
||||
@@ -243,7 +246,7 @@ class crm_claim_product_return(osv.osv):
|
||||
_description = "Add product return functionalities, product exchange and aftersale outsourcing to CRM claim"
|
||||
_inherit = 'crm.claim'
|
||||
_columns = {
|
||||
'sequence': fields.char('Sequence', size=128, required=True,readonly=True, help="Company internal claim unique number"),
|
||||
'sequence': fields.char('Sequence', 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"),
|
||||
|
||||
@@ -101,7 +101,7 @@
|
||||
<field name="name"/>
|
||||
<separator string="Returned good" colspan="4"/>
|
||||
<group col="6" colspan="4">
|
||||
<field name="invoice_id" domain="[('type', '=', 'out_invoice')]" />
|
||||
<field name="invoice_id"/> <!-- domain="[('type', '=', 'out_invoice')]" -->
|
||||
<field name="product_id"/>
|
||||
<field name="prodlot_id"/>
|
||||
<field name="product_returned_quantity"/>
|
||||
@@ -283,18 +283,34 @@
|
||||
<act_window
|
||||
context="{'search_default_partner_id': [partner_id],}"
|
||||
domain="[('type', '=', 'out_invoice')]"
|
||||
id="act_crm_claim_rma_invoice"
|
||||
name="Partner invoices"
|
||||
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
|
||||
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"
|
||||
src_model="crm.claim"/>
|
||||
<!-- Right side link to refunds -->
|
||||
<act_window
|
||||
context="{'search_default_partner_id': [partner_id],}"
|
||||
domain="[('type', '=', 'out_refund')]"
|
||||
id="act_crm_claim_rma_refunds"
|
||||
name="Partner refunds"
|
||||
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
|
||||
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
|
||||
domain="[('type', '=', 'in'),('partner_id', 'in', [partner_id])]"
|
||||
|
||||
@@ -1,7 +1,10 @@
|
||||
"id","name","model_id","group_id","perm_read","perm_write","perm_create","perm_unlink"
|
||||
"access_substate_user","substate.substate.user","substate.substate","Sales / User","True","True","True",
|
||||
"access_return_line_user","return.line.user","return.line","Sales / User","True","True","True",
|
||||
"access_exchange_user","product.exchange.user","product.exchange","Sales / User","True","True","True",
|
||||
"access_substate_user","substate.substate.user","substate.substate","Sales / User - All Leads","True","True","True",
|
||||
"access_return_line_user","return.line.user","return.line","Sales / User - All Leads","True","True","True",
|
||||
"access_exchange_user","product.exchange.user","product.exchange","Sales / User - All Leads","True","True","True",
|
||||
"access_substate_manager","substate.substate.manager","substate.substate","Sales / Manager","True","True","True","True"
|
||||
"access_return_line_manager","return.line.manager","return.line","Sales / Manager","True","True","True","True"
|
||||
"access_exchange_manager","product.exchange.manager","product.exchange","Sales / Manager","True","True","True","True"
|
||||
"access_substate_user","substate.substate.user","substate.substate","Sales / User - Own Leads Only","True","True","True",
|
||||
"access_return_line_user","return.line.user","return.line","Sales / User - Own Leads Only","True","True","True",
|
||||
"access_exchange_user","product.exchange.user","product.exchange","Sales / User - Own Leads Only","True","True","True",
|
||||
|
||||
|
@@ -29,7 +29,7 @@ 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', 'exchange_rel_refund', 'wizard_id', 'temp_exchange_line_id', 'Selected exchange lines'),
|
||||
'exchange_line_ids' : fields.many2many('temp.exchange.line', string='Selected exchange lines'),
|
||||
}
|
||||
|
||||
# Get selected lines to add to exchange
|
||||
@@ -45,6 +45,8 @@ class exchange_from_returned_lines(osv.osv_memory):
|
||||
'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
|
||||
|
||||
|
||||
@@ -25,11 +25,11 @@ import pooler
|
||||
import time
|
||||
|
||||
# Class to create a picking out from selected exchange lines
|
||||
class picking_out_from_returned_lines(osv.osv_memory):
|
||||
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', 'return_rel_exchange', 'wizard_id', 'temp_exchange_line_id', 'Selected exchange lines'),
|
||||
'exchange_line_ids' : fields.many2many('temp.exchange.line', string='Selected exchange lines'),
|
||||
}
|
||||
|
||||
# Get selected lines to add to picking in
|
||||
@@ -111,6 +111,6 @@ class picking_out_from_returned_lines(osv.osv_memory):
|
||||
}
|
||||
return view
|
||||
|
||||
picking_out_from_returned_lines()
|
||||
picking_out_from_exchange_lines()
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
|
||||
@@ -30,7 +30,7 @@ class picking_in_from_returned_lines(osv.osv_memory):
|
||||
_description='Wizard to create a picking in from selected return lines'
|
||||
_columns = {
|
||||
'return_line_location' : fields.many2one('stock.location', 'Dest. Location',help="Location where the system will stock the returned products.", select=True),
|
||||
'return_line_ids' : fields.many2many('temp.return.line', 'return_rel_refund', 'wizard_id', 'temp_return_line_id', 'Selected return lines'),
|
||||
'return_line_ids' : fields.many2many('temp.return.line',string='Selected return lines'),
|
||||
}
|
||||
|
||||
# Get selected lines to add to picking in
|
||||
@@ -130,7 +130,7 @@ 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 = {
|
||||
'return_line_ids' : fields.many2many('temp.return.line', 'return_rel_refund', 'wizard_id', 'temp_return_line_id', 'Selected return lines'),
|
||||
'return_line_ids' : fields.many2many('temp.return.line', string='Selected return lines'),
|
||||
}
|
||||
|
||||
# Get selected lines to add to picking in
|
||||
@@ -155,7 +155,7 @@ class picking_out_from_returned_lines(osv.osv_memory):
|
||||
}
|
||||
|
||||
# If "Cancel" button pressed
|
||||
def action_cancel(self,cr,uid,ids,conect=None):
|
||||
def action_cancel(self,cr,uid,ids,context=None):
|
||||
return {'type': 'ir.actions.act_window_close',}
|
||||
|
||||
# If "Create" button pressed
|
||||
|
||||
@@ -29,7 +29,7 @@ class refund_from_returned_lines(osv.osv_memory):
|
||||
_description='Wizard to create an refund for selected product return lines'
|
||||
_columns = {
|
||||
'refund_journal' : fields.many2one('account.journal', 'Refund journal', select=True),
|
||||
'return_line_ids' : fields.many2many('temp.return.line', 'return_rel_refund', 'wizard_id', 'temp_return_line_id', 'Selected return lines'),
|
||||
'return_line_ids' : fields.many2many('temp.return.line', string='Selected return lines'),
|
||||
}
|
||||
|
||||
# Get selected lines to add to picking in
|
||||
@@ -53,7 +53,6 @@ class refund_from_returned_lines(osv.osv_memory):
|
||||
def _get_journal(self, cr, uid,context):
|
||||
#('company_id','=',claim_id.company_id.id)
|
||||
# ,('refund_journal','=','True')
|
||||
print "get journal with refund_journal=True: ",self.pool.get('account.journal').search(cr, uid, [('type','=','sale_refund'),('refund_journal','=','True')],limit=1)
|
||||
return self.pool.get('account.journal').search(cr, uid, [('type','=','sale_refund')],limit=1)[0]
|
||||
|
||||
_defaults = {
|
||||
@@ -62,7 +61,7 @@ class refund_from_returned_lines(osv.osv_memory):
|
||||
}
|
||||
|
||||
# On "Cancel" button
|
||||
def action_cancel(self,cr,uid,ids,conect=None):
|
||||
def action_cancel(self,cr,uid,ids,context=None):
|
||||
return {'type': 'ir.actions.act_window_close',}
|
||||
|
||||
# On "Create" button
|
||||
@@ -79,7 +78,7 @@ class refund_from_returned_lines(osv.osv_memory):
|
||||
invoice_id = self.pool.get('account.invoice').create(cr, uid, {
|
||||
'claim_origine' : "none",
|
||||
'origin' : claim_id.id,
|
||||
'type' : 'out_refund',
|
||||
'type' : invoice_type,
|
||||
'state' : 'draft',
|
||||
'partner_id' : claim_id.partner_id.id,
|
||||
'user_id' : uid,
|
||||
@@ -96,7 +95,8 @@ class refund_from_returned_lines(osv.osv_memory):
|
||||
})
|
||||
# Create invoice lines
|
||||
for refund_line in refund.return_line_ids:
|
||||
invoice_line_id = self.pool.get('account.invoice.line').create(cr, uid, {
|
||||
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.id,
|
||||
'invoice_id' : invoice_id,
|
||||
@@ -111,7 +111,9 @@ class refund_from_returned_lines(osv.osv_memory):
|
||||
'company_id' : claim_id.company_id.id,
|
||||
'partner_id' : refund_line.invoice_id.partner_id.id,
|
||||
'note': 'RMA Refound',
|
||||
})
|
||||
})
|
||||
else:
|
||||
raise osv.except_osv(_('Error !'), _('Cannot find any invoice for the return line!'))
|
||||
return {
|
||||
'name': 'Customer Refounds',
|
||||
'view_type': 'form',
|
||||
|
||||
@@ -98,7 +98,7 @@ 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 = {
|
||||
'return_line_ids' : fields.many2many('temp.return.line', 'return_rel', 'wizard_id', 'temp_return_line_id', 'Return lines'),
|
||||
'return_line_ids' : fields.many2many('temp.return.line', string='Return lines'),
|
||||
}
|
||||
|
||||
# Get possible returns from invoice
|
||||
|
||||
@@ -82,7 +82,7 @@ class returned_lines_from_serial(osv.osv_memory):
|
||||
|
||||
# Get partner from case is set to filter serials
|
||||
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']
|
||||
return self.pool.get('crm.claim').read(cr, uid, context['active_id'], ['partner_id'])['partner_id'][0]
|
||||
|
||||
_defaults = {
|
||||
'qty_1': lambda *a: 1.0,
|
||||
@@ -134,7 +134,7 @@ class returned_lines_from_serial(osv.osv_memory):
|
||||
# Refactor code : create 1 "createmethode" called by each if with values as parameters
|
||||
return_line.create(cr, uid, {
|
||||
'claim_id': context['active_id'],
|
||||
'name': result.claim_1,
|
||||
'claim_origine': result.claim_1,
|
||||
'product_id' : self.get_product_id(cr, uid,ids,result.prodlot_id_1.id,context),
|
||||
#'invoice_id' : self.prodlot_2_invoice(cr, uid,[result.prodlot_id_1.id],[result.prodlot_id_1.product_id.id]), #PRODLOT_ID can be in many invoice !!
|
||||
'product_returned_quantity' : result.qty_1,
|
||||
@@ -147,7 +147,7 @@ class returned_lines_from_serial(osv.osv_memory):
|
||||
if result.prodlot_id_2.id :
|
||||
return_line.create(cr, uid, {
|
||||
'claim_id': context['active_id'],
|
||||
'name': result.claim_2,
|
||||
'claim_origine': result.claim_2,
|
||||
'product_id' : self.get_product_id(cr, uid,ids,result.prodlot_id_2.id,context),
|
||||
# 'invoice_id' : self.prodlot_2_invoice(cr, uid,[result.prodlot_id_1.id]),
|
||||
'product_returned_quantity' : result.qty_2,
|
||||
@@ -160,7 +160,7 @@ class returned_lines_from_serial(osv.osv_memory):
|
||||
if result.prodlot_id_3.id :
|
||||
return_line.create(cr, uid, {
|
||||
'claim_id': context['active_id'],
|
||||
'name': result.claim_3,
|
||||
'claim_origine': result.claim_3,
|
||||
'product_id' : self.get_product_id(cr, uid,ids,result.prodlot_id_3.id,context),
|
||||
# 'invoice_id' : self.prodlot_2_invoice(cr, uid,[result.prodlot_id_1.id]),
|
||||
'product_returned_quantity' : result.qty_3,
|
||||
@@ -173,7 +173,7 @@ class returned_lines_from_serial(osv.osv_memory):
|
||||
if result.prodlot_id_4.id :
|
||||
return_line.create(cr, uid, {
|
||||
'claim_id': context['active_id'],
|
||||
'name': result.claim_4,
|
||||
'claim_origine': result.claim_4,
|
||||
'product_id' : self.get_product_id(cr, uid,ids,result.prodlot_id_4.id,context),
|
||||
# 'invoice_id' : self.prodlot_2_invoice(cr, uid,[result.prodlot_id_1.id]),
|
||||
'product_returned_quantity' : result.qty_4,
|
||||
@@ -186,7 +186,7 @@ class returned_lines_from_serial(osv.osv_memory):
|
||||
if result.prodlot_id_5.id :
|
||||
return_line.create(cr, uid, {
|
||||
'claim_id': context['active_id'],
|
||||
'name': result.claim_5,
|
||||
'claim_origine': result.claim_5,
|
||||
'product_id' : self.get_product_id(cr, uid,ids,result.prodlot_id_5.id,context),
|
||||
# 'invoice_id' : self.prodlot_2_invoice(cr, uid,[result.prodlot_id_1.id],[result.prodlot_id_1.product_id.id]),
|
||||
'product_returned_quantity' : result.qty_5,
|
||||
|
||||
@@ -47,7 +47,7 @@ class product_supplierinfo(osv.osv):
|
||||
else:
|
||||
return [
|
||||
('company','Company'),
|
||||
('brand','Brand manufacturer'),
|
||||
('supplier','Supplier'),
|
||||
('other','Other'),]
|
||||
|
||||
# Get selected lines to add to exchange
|
||||
|
||||
Reference in New Issue
Block a user