From 97be00f70d6094e4e66ccd8d25bb9ecafe1b5320 Mon Sep 17 00:00:00 2001 From: Maxime Chambreuil Date: Tue, 6 Aug 2013 16:33:08 -0400 Subject: [PATCH] [UPD] Remove references to res.partner.address --- product_warranty/product_warranty.py | 37 ++++++++++++++-------------- 1 file changed, 18 insertions(+), 19 deletions(-) diff --git a/product_warranty/product_warranty.py b/product_warranty/product_warranty.py index 7ed9f7eb..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,18 +45,18 @@ 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): # 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 +70,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,13 +88,12 @@ 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', 'return_instructions': _get_default_instructions, } -product_supplierinfo() # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: