From 0bc05aa201a0e9c118026c2911245778c30cab3b Mon Sep 17 00:00:00 2001 From: Maxime Chambreuil Date: Tue, 6 Aug 2013 16:33:08 -0400 Subject: [PATCH 1/5] [UPD] Remove references to res.partner.address --- product_warranty/product_warranty.py | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/product_warranty/product_warranty.py b/product_warranty/product_warranty.py index 7ed9f7eb..d3d7d2e3 100644 --- a/product_warranty/product_warranty.py +++ b/product_warranty/product_warranty.py @@ -59,7 +59,7 @@ class product_supplierinfo(osv.osv): # Method to return the partner delivery address or if none, the default address # dedicated_delivery_address stand for the case a new type of address more particularly dedicated to return delivery would be implemented. result ={} - address_obj = self.pool.get('res.partner.address') + address_obj = self.pool.get('res.partner') for supplier_info in self.browse(cr, uid, ids, context=context): result[supplier_info.id] = {} address_id = False @@ -73,14 +73,17 @@ class product_supplierinfo(osv.osv): partner_id = supplier_info.product_id.product_brand_id.partner_id.id else: partner_id = supplier_info.company_id.partner_id.id - address_id = address_obj.search(cr, uid, [('partner_id', '=', partner_id), ('type', 'like', 'dedicated_delivery')], context=context) - if not address_id: - address_id = address_obj.search(cr, uid, [('partner_id','=', partner_id), ('type','like','delivery')], context=context) - if not address_id: - address_id = address_obj.search(cr, uid, [('partner_id', '=', partner_id), ('type', 'like', 'default')], context=context) - if not address_id: - raise osv.except_osv(_('Error !'), _('No address define for the %s!') % return_partner) - result[supplier_info.id] = address_id[0] +# TODO : Find the partner with a delivery address, child of the partner +# v6.1 code with res.partner.address : +# address_id = address_obj.search(cr, uid, [('partner_id', '=', partner_id), ('type', 'like', 'dedicated_delivery')], context=context) +# if not address_id: +# address_id = address_obj.search(cr, uid, [('partner_id','=', partner_id), ('type','like','delivery')], context=context) +# if not address_id: +# address_id = address_obj.search(cr, uid, [('partner_id', '=', partner_id), ('type', 'like', 'default')], context=context) +# if not address_id: +# raise osv.except_osv(_('Error !'), _('No address define for the %s!') % return_partner) +# #result[supplier_info.id] = address_id[0] + result[supplier_info.id] = partner_id return result _columns = { @@ -88,7 +91,7 @@ class product_supplierinfo(osv.osv): "warranty_return_partner" : fields.selection(get_warranty_return_partner, 'Warrantee return', size=128, help="Who is in charge of the warranty return treatment toward the end customer. Company will use the current compagny delivery or default address and so on for supplier and brand manufacturer. Doesn't necessarly mean that the warranty to be applied is the one of the return partner (ie: can be returned to the company and be under the brand warranty"), 'return_instructions': fields.many2one('return.instruction', 'Instructions',help="Instructions for product return"), 'active_supplier' : fields.boolean('Active supplier', help=""), - 'warranty_return_address': fields.function(_get_warranty_return_address, type='many2one', relation='res.partner.address', string="Warranty return address"), + 'warranty_return_address': fields.function(_get_warranty_return_address, type='many2one', relation='res.partner', string="Warranty return address"), } _defaults = { 'warranty_return_partner': lambda *a: 'company', From e6f1946582bbb8fa7230fb692e4580428a7db5cd Mon Sep 17 00:00:00 2001 From: Romain Deheele Date: Mon, 19 Aug 2013 13:50:47 +0200 Subject: [PATCH 2/5] [FIX] fix picking views links --- crm_claim_rma/crm_claim_rma_view.xml | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/crm_claim_rma/crm_claim_rma_view.xml b/crm_claim_rma/crm_claim_rma_view.xml index 07acf8ff..b3975386 100644 --- a/crm_claim_rma/crm_claim_rma_view.xml +++ b/crm_claim_rma/crm_claim_rma_view.xml @@ -323,15 +323,17 @@ res_model="account.invoice" src_model="crm.claim"/> - Date: Mon, 19 Aug 2013 13:56:08 +0200 Subject: [PATCH 3/5] [UPD] remove references to res.partner.address in wizards --- crm_claim_rma/wizard/claim_make_picking.py | 5 ++-- .../wizard/claim_make_picking_from_picking.py | 4 +-- .../wizard/picking_from_exchange_lines.py | 20 +++++++------- .../wizard/picking_from_returned_lines.py | 26 +++++++++---------- .../wizard/refund_from_returned_lines.py | 26 +++++++++---------- 5 files changed, 40 insertions(+), 41 deletions(-) diff --git a/crm_claim_rma/wizard/claim_make_picking.py b/crm_claim_rma/wizard/claim_make_picking.py index 1ac78f63..ebf38794 100644 --- a/crm_claim_rma/wizard/claim_make_picking.py +++ b/crm_claim_rma/wizard/claim_make_picking.py @@ -116,7 +116,6 @@ class claim_make_picking(osv.osv_memory): view_name = 'stock.picking.in.form' view_id = view_obj.search(cr, uid, [ ('xml_id', '=', view_xml_id), - ('model', '=', 'stock.picking'), ('type', '=', 'form'), ('name', '=', view_name) ], context=context)[0] @@ -130,7 +129,7 @@ class claim_make_picking(osv.osv_memory): 'move_type': 'one', # direct 'state': 'draft', 'date': time.strftime(DEFAULT_SERVER_DATETIME_FORMAT), - 'address_id': claim.partner_address_id.id, + 'partner_id': claim.partner_id.id, 'invoice_state': "none", 'company_id': claim.company_id.id, 'location_id': wizard.claim_line_source_location.id, @@ -150,7 +149,7 @@ class claim_make_picking(osv.osv_memory): 'product_id': wizard_claim_line.product_id.id, 'product_qty': wizard_claim_line.product_returned_quantity, 'product_uom': wizard_claim_line.product_id.uom_id.id, - 'address_id': claim.partner_address_id.id, + 'partner_id': claim.partner_id.id, 'prodlot_id': wizard_claim_line.prodlot_id.id, # 'tracking_id': 'picking_id': picking_id, diff --git a/crm_claim_rma/wizard/claim_make_picking_from_picking.py b/crm_claim_rma/wizard/claim_make_picking_from_picking.py index 7951d96c..6c0d9809 100644 --- a/crm_claim_rma/wizard/claim_make_picking_from_picking.py +++ b/crm_claim_rma/wizard/claim_make_picking_from_picking.py @@ -93,7 +93,7 @@ class claim_make_picking_from_picking(osv.osv_memory): 'move_type': 'one', # direct 'state': 'draft', 'date': time.strftime(DEFAULT_SERVER_DATETIME_FORMAT), - 'address_id': prev_picking.address_id.id, + 'partner_id': prev_picking.partner_id.id, 'invoice_state': "none", 'company_id': prev_picking.company_id.id, 'location_id': wizard.picking_line_source_location.id, @@ -112,7 +112,7 @@ class claim_make_picking_from_picking(osv.osv_memory): 'product_id': wizard_picking_line.product_id.id, 'product_qty': wizard_picking_line.product_qty, 'product_uom': wizard_picking_line.product_uom.id, - 'address_id': prev_picking.address_id.id, + 'partner_id': prev_picking.partner_id.id, 'prodlot_id': wizard_picking_line.prodlot_id.id, # 'tracking_id': 'picking_id': picking_id, diff --git a/crm_claim_rma/wizard/picking_from_exchange_lines.py b/crm_claim_rma/wizard/picking_from_exchange_lines.py index c0e5efdd..ac3503a2 100644 --- a/crm_claim_rma/wizard/picking_from_exchange_lines.py +++ b/crm_claim_rma/wizard/picking_from_exchange_lines.py @@ -31,7 +31,7 @@ class picking_out_from_exchange_lines(osv.osv_memory): _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'] @@ -46,13 +46,13 @@ class picking_out_from_exchange_lines(osv.osv_memory): '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, + 'replacement_prodlot_id': line.replacement_product_serial.id, })) - return M2M - + return M2M + _defaults = { 'exchange_line_ids': _get_selected_lines, - } + } # If "Cancel" button pressed def action_cancel(self,cr,uid,ids,conect=None): @@ -70,13 +70,13 @@ class picking_out_from_exchange_lines(osv.osv_memory): 'move_type': 'one', # direct 'state': 'draft', 'date': time.strftime('%Y-%m-%d %H:%M:%S'), - 'address_id': claim_id.partner_address_id.id, + 'partner_id': claim_id.partner_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', + 'note' : 'RMA picking in', }) # Create picking lines for exchange_line in exchange_lines.exchange_line_ids: @@ -89,7 +89,7 @@ class picking_out_from_exchange_lines(osv.osv_memory): '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, + 'partner_id': claim_id.partner_id.id, 'prodlot_id': exchange_line.replacement_prodlot_id, # 'tracking_id': 'picking_id': picking_id, @@ -99,7 +99,7 @@ class picking_out_from_exchange_lines(osv.osv_memory): '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', + 'note': 'RMA Refound', }) view = { 'name': 'Customer Picking OUT', @@ -110,7 +110,7 @@ class picking_out_from_exchange_lines(osv.osv_memory): 'type': 'ir.actions.act_window', } return view - + picking_out_from_exchange_lines() # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/crm_claim_rma/wizard/picking_from_returned_lines.py b/crm_claim_rma/wizard/picking_from_returned_lines.py index b7f936c6..bf70929e 100644 --- a/crm_claim_rma/wizard/picking_from_returned_lines.py +++ b/crm_claim_rma/wizard/picking_from_returned_lines.py @@ -32,7 +32,7 @@ class picking_in_from_returned_lines(osv.osv_memory): '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'] @@ -53,12 +53,12 @@ class picking_in_from_returned_lines(osv.osv_memory): # 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',} @@ -84,7 +84,7 @@ class picking_in_from_returned_lines(osv.osv_memory): 'move_type': 'one', # direct 'state': 'draft', 'date': time.strftime('%Y-%m-%d %H:%M:%S'), - 'address_id': claim_id.partner_address_id.id, + 'partner_id': claim_id.partner_id.id, 'invoice_state': "none", 'company_id': claim_id.company_id.id, 'location_id': location, @@ -103,7 +103,7 @@ class picking_in_from_returned_lines(osv.osv_memory): '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, + 'partner_id': claim_id.partner_id.id, 'prodlot_id': picking_line.prodlot_id.id, # 'tracking_id': 'picking_id': picking_id, @@ -125,7 +125,7 @@ class picking_in_from_returned_lines(osv.osv_memory): 'res_model': 'stock.picking', 'type': 'ir.actions.act_window', } - + picking_in_from_returned_lines() # Class to create a picking out from selected return lines @@ -135,7 +135,7 @@ class picking_out_from_returned_lines(osv.osv_memory): _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'] @@ -151,11 +151,11 @@ class picking_out_from_returned_lines(osv.osv_memory): 'prodlot_id' : line.prodlot_id.id, 'price_unit' : line.unit_sale_price, })) - return M2M - + return M2M + _defaults = { 'claim_line_ids': _get_selected_lines, - } + } # If "Cancel" button pressed def action_cancel(self,cr,uid,ids,context=None): @@ -180,7 +180,7 @@ class picking_out_from_returned_lines(osv.osv_memory): 'move_type': 'one', # direct 'state': 'draft', 'date': time.strftime('%Y-%m-%d %H:%M:%S'), - 'address_id': claim_id.partner_address_id.id, + 'partner_id': claim_id.partner_id.id, 'invoice_state': "none", 'company_id': claim_id.company_id.id, # 'stock_journal_id': fields.many2one('stock.journal','Stock Journal', select=True), @@ -200,7 +200,7 @@ class picking_out_from_returned_lines(osv.osv_memory): '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, + 'partner_id': claim_id.partner_id.id, 'prodlot_id': picking_line.prodlot_id.id, # 'tracking_id': 'picking_id': picking_id, diff --git a/crm_claim_rma/wizard/refund_from_returned_lines.py b/crm_claim_rma/wizard/refund_from_returned_lines.py index b75bb80b..612d6add 100644 --- a/crm_claim_rma/wizard/refund_from_returned_lines.py +++ b/crm_claim_rma/wizard/refund_from_returned_lines.py @@ -31,7 +31,7 @@ class refund_from_returned_lines(osv.osv_memory): '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'] @@ -47,18 +47,18 @@ class refund_from_returned_lines(osv.osv_memory): 'prodlot_id' : line.prodlot_id.id, 'price_unit' : line.unit_sale_price, })) - return M2M + 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): @@ -85,22 +85,22 @@ class refund_from_returned_lines(osv.osv_memory): '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, + 'partner_id' : claim_id.partner_id.id, + 'commercial_partner_id' : claim_id.partner_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: + }) + # 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, + '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, @@ -111,7 +111,7 @@ class refund_from_returned_lines(osv.osv_memory): # 'account_analytic_id': 'company_id' : claim_id.company_id.id, 'partner_id' : refund_line.invoice_id.partner_id.id, - 'note': 'RMA Refund', + 'note': 'RMA Refund', }) else: raise osv.except_osv(_('Error !'), _('Cannot find any invoice for the return line!')) @@ -123,7 +123,7 @@ class refund_from_returned_lines(osv.osv_memory): 'res_model': 'account.invoice', 'type': 'ir.actions.act_window', } - + refund_from_returned_lines() # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: From a6f810689adf43e74839f90ac1591150b4a73c65 Mon Sep 17 00:00:00 2001 From: Maxime Chambreuil Date: Mon, 19 Aug 2013 18:04:13 -0400 Subject: [PATCH 4/5] [UPD] Finish upgrade to v7 --- product_warranty/product_warranty.py | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/product_warranty/product_warranty.py b/product_warranty/product_warranty.py index d3d7d2e3..e63abdbe 100644 --- a/product_warranty/product_warranty.py +++ b/product_warranty/product_warranty.py @@ -20,11 +20,10 @@ #along with this program. If not, see . # ######################################################################### -from osv import fields, osv +from openerp.osv import orm, fields from tools.translate import _ -#===== -class return_instruction(osv.osv): +class return_instruction(orm.Model): _name = "return.instruction" _description = "Instructions for product return" _columns = { @@ -32,10 +31,8 @@ class return_instruction(osv.osv): 'instructions' : fields.text('Instructions', help="Instructions for product return"), 'is_default' : fields.boolean('Is default', help="If is default, will be use to set the default value in supplier infos. Be careful to have only one default"), } -return_instruction() -#===== -class product_supplierinfo(osv.osv): +class product_supplierinfo(orm.Model): _inherit = "product.supplierinfo" def get_warranty_return_partner(self, cr, uid, context=None): @@ -48,11 +45,11 @@ class product_supplierinfo(osv.osv): return result # Get selected lines to add to exchange - def _get_default_instructions(self, cr, uid,context): + def _get_default_instructions(self, cr, uid, context=None): instruction_ids = self.pool.get('return.instruction').search(cr, uid, [('is_default','=','FALSE')]) if instruction_ids: return instruction_ids[0] - # TO DO f(supplier) + other. + # TODO f(supplier) + other. return False def _get_warranty_return_address(self, cr, uid, ids, field_names, arg, context=None): @@ -98,6 +95,5 @@ class product_supplierinfo(osv.osv): 'return_instructions': _get_default_instructions, } -product_supplierinfo() # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: From cf18e9f0e42a6e80fe6472364de054e4a0dff719 Mon Sep 17 00:00:00 2001 From: Maxime Chambreuil Date: Mon, 19 Aug 2013 18:20:51 -0400 Subject: [PATCH 5/5] [UPD] Upgrade and cleanup --- crm_claim_rma/crm_claim_rma.py | 131 +++++---------------------------- 1 file changed, 18 insertions(+), 113 deletions(-) diff --git a/crm_claim_rma/crm_claim_rma.py b/crm_claim_rma/crm_claim_rma.py index a95fb98d..0b69e327 100644 --- a/crm_claim_rma/crm_claim_rma.py +++ b/crm_claim_rma/crm_claim_rma.py @@ -21,7 +21,7 @@ #along with this program. If not, see . # ######################################################################### -from osv import fields, osv +from openerp.osv import fields, orm from crm import crm from datetime import datetime from dateutil.relativedelta import relativedelta @@ -29,8 +29,8 @@ import time from tools.translate import _ from tools import DEFAULT_SERVER_DATE_FORMAT -#===== TO REFACTORED IN A GENERIC MODULE -class substate_substate(osv.osv): +#TODO: REFACTOR IN A GENERIC MODULE +class substate_substate(orm.Model): """ To precise a state (state=refused; substates= reason 1, 2,...) """ @@ -41,10 +41,8 @@ class substate_substate(osv.osv): '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) """ @@ -52,21 +50,14 @@ class claim_line(osv.osv): _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): + def _line_total_amount(self, cr, uid, ids, field_name, arg, context=None): res = {} for line in self.browse(cr,uid,ids): res[line.id] = line.unit_sale_price*line.product_returned_quantity return res -# def _get_claim_seq(self, cr, uid, ids, field_name, arg,context): -# res = {} -# for line in self.browse(cr,uid,ids): -# res[line.id] = line.claim_id.sequence -# 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'), @@ -76,17 +67,14 @@ class claim_line(osv.osv): ('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 + 'applicable_guarantee': fields.selection([('us','Company'),('supplier','Supplier'),('brand','Brand manufacturer')], 'Warranty type'),# TODO: Replace with function field. 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, + 'warning': fields.char('Warranty', size=64, readonly=True,help="If warranty has expired"), 'warranty_type': fields.char('Warranty type', size=64, readonly=True,help="from product form"), "warranty_return_partner" : fields.many2one('res.partner', '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"), @@ -110,13 +98,13 @@ class claim_line(osv.osv): } # Method to calculate warranty limit - def set_warranty_limit(self, cr, uid, ids, context, claim_line): + def set_warranty_limit(self, cr, uid, ids, claim_line, context=None): 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 !!! + 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) # TODO: 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) else : @@ -132,7 +120,7 @@ class claim_line(osv.osv): return True # Method to calculate warranty return address - def set_warranty_return_address(self, cr, uid, ids, context, claim_line): + def set_warranty_return_address(self, cr, uid, ids, claim_line, context=None): return_address = None warranty_type = 'company' seller = claim_line.product_id.seller_info_id @@ -177,76 +165,18 @@ class claim_line(osv.osv): return True # Method to calculate warranty limit and validity - def set_warranty(self, cr, uid, ids,context=None): + def set_warranty(self, cr, uid, ids, context=None): for claim_line in self.browse(cr, uid, ids, context=context): if claim_line.product_id and claim_line.invoice_line_id: - self.set_warranty_limit(cr, uid, ids, context, claim_line) - self.set_warranty_return_address(cr, uid, ids, context, claim_line) + self.set_warranty_limit(cr, uid, ids, claim_line, context) + self.set_warranty_return_address(cr, uid, ids, claim_line, context) else: raise osv.except_osv(_('Error !'), _('PLEASE SET PRODUCT & INVOICE!')) return True -#TODO add the option split the claim_line in order to manage the same product separately +#TODO add the option to 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 = { @@ -263,8 +193,8 @@ class crm_claim(osv.osv): # Financial management '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_revenue': fields.float('Real revenue'), + 'real_cost': fields.float('Real cost'), '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'), @@ -275,31 +205,8 @@ class crm_claim(osv.osv): '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_address_id(self, cr, uid, ids, add, email=False): + def onchange_partner_address_id(self, cr, uid, ids, add, email=False, context=None): 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']: @@ -331,6 +238,4 @@ 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: