mirror of
https://github.com/OCA/rma.git
synced 2025-02-16 17:11:47 +02:00
[IMP] product_warranty: add waranty_return_address on the product_supplierinfo
This commit is contained in:
committed by
Maxime Chambreuil
parent
d45660b12f
commit
51a0daee3a
@@ -4,7 +4,7 @@
|
|||||||
# #
|
# #
|
||||||
#########################################################################
|
#########################################################################
|
||||||
# #
|
# #
|
||||||
# Copyright (C) 2009-2011 Akretion, Emmanuel Samyn #
|
# Copyright (C) 2009-2011 Akretion, Emmanuel Samyn, Benoît Guillot #
|
||||||
# #
|
# #
|
||||||
#This program is free software: you can redistribute it and/or modify #
|
#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 #
|
#it under the terms of the GNU General Public License as published by #
|
||||||
@@ -21,6 +21,7 @@
|
|||||||
#########################################################################
|
#########################################################################
|
||||||
|
|
||||||
from osv import fields, osv
|
from osv import fields, osv
|
||||||
|
from tools.translate import _
|
||||||
|
|
||||||
#=====
|
#=====
|
||||||
class return_instruction(osv.osv):
|
class return_instruction(osv.osv):
|
||||||
@@ -38,37 +39,62 @@ class product_supplierinfo(osv.osv):
|
|||||||
_inherit = "product.supplierinfo"
|
_inherit = "product.supplierinfo"
|
||||||
|
|
||||||
def get_warranty_return_partner(self, cr, uid, context=None):
|
def get_warranty_return_partner(self, cr, uid, context=None):
|
||||||
|
result = [
|
||||||
|
('company','Company'),
|
||||||
|
('supplier','Supplier'),
|
||||||
|
('other','Other'),]
|
||||||
if self.pool.get('ir.module.module').search(cr, uid, [('name','like','product_brand'),('state','like','installed')]):
|
if self.pool.get('ir.module.module').search(cr, uid, [('name','like','product_brand'),('state','like','installed')]):
|
||||||
return [
|
result.append(('brand','Brand manufacturer'),)
|
||||||
('company','Company'),
|
return result
|
||||||
('supplier','Supplier'),
|
|
||||||
('brand','Brand manufacturer'),
|
|
||||||
('other','Other'),]
|
|
||||||
else:
|
|
||||||
return [
|
|
||||||
('company','Company'),
|
|
||||||
('supplier','Supplier'),
|
|
||||||
('other','Other'),]
|
|
||||||
|
|
||||||
# Get selected lines to add to exchange
|
# Get selected lines to add to exchange
|
||||||
def _get_default_instructions(self, cr, uid,context):
|
def _get_default_instructions(self, cr, uid,context):
|
||||||
instruction_ids = self.pool.get('return.instruction').search(cr, uid, [('is_default','=','FALSE')])
|
instruction_ids = self.pool.get('return.instruction').search(cr, uid, [('is_default','=','FALSE')])
|
||||||
if instruction_ids:
|
if instruction_ids:
|
||||||
return instruction_ids[0]
|
return instruction_ids[0]
|
||||||
# TO DO f(supplier) + other...
|
# TO DO f(supplier) + other.
|
||||||
return False
|
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')
|
||||||
|
for supplier_info in self.browse(cr, uid, ids, context=context):
|
||||||
|
result[supplier_info.id] = {}
|
||||||
|
address_id = False
|
||||||
|
return_partner = supplier_info.warranty_return_partner
|
||||||
|
if return_partner:
|
||||||
|
if return_partner == 'supplier':
|
||||||
|
partner_id = supplier_info.name.id
|
||||||
|
elif sreturn_partner == 'brand':
|
||||||
|
if not supplier_info.product_id.product_brand_id.partner_id:
|
||||||
|
raise osv.except_osv(_('Error !'), _('You need to define a partner for the brand of the product !'))
|
||||||
|
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]
|
||||||
|
return result
|
||||||
|
|
||||||
_columns = {
|
_columns = {
|
||||||
"warranty_duration" : fields.float('Warranty', help="Warranty in month for this product/supplier relation. Only for company/supplier relation (purchase order) ; the customer/company relation (sale order) always use the product main warranty field"),
|
"warranty_duration" : fields.float('Warranty', help="Warranty in month for this product/supplier relation. Only for company/supplier relation (purchase order) ; the customer/company relation (sale order) always use the product main warranty field"),
|
||||||
"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"),
|
"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"),
|
'return_instructions': fields.many2one('return.instruction', 'Instructions',help="Instructions for product return"),
|
||||||
'active_supplier' : fields.boolean('Active supplier', help=""),
|
'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"),
|
||||||
}
|
}
|
||||||
_defaults = {
|
_defaults = {
|
||||||
'warranty_return_partner': lambda *a: 'company',
|
'warranty_return_partner': lambda *a: 'company',
|
||||||
'return_instructions': _get_default_instructions,
|
'return_instructions': _get_default_instructions,
|
||||||
}
|
}
|
||||||
|
|
||||||
product_supplierinfo()
|
product_supplierinfo()
|
||||||
|
|
||||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||||
|
|||||||
@@ -23,33 +23,33 @@
|
|||||||
<data>
|
<data>
|
||||||
<!-- return instructions -->
|
<!-- return instructions -->
|
||||||
<!-- supplier info tree view -->
|
<!-- supplier info tree view -->
|
||||||
<record model="ir.ui.view" id="product_return_instructions_tree_view">
|
<record model="ir.ui.view" id="product_return_instructions_tree_view">
|
||||||
<field name="name">product.return.instructions.tree</field>
|
<field name="name">product.return.instructions.tree</field>
|
||||||
<field name="model">return.instruction</field>
|
<field name="model">return.instruction</field>
|
||||||
<field name="type">tree</field>
|
<field name="type">tree</field>
|
||||||
<field name="arch" type="xml">
|
<field name="arch" type="xml">
|
||||||
<tree string="Return instructions">
|
<tree string="Return instructions">
|
||||||
<field name="name"/>
|
<field name="name"/>
|
||||||
<field name="instructions"/>
|
<field name="instructions"/>
|
||||||
<field name="is_default"/>
|
<field name="is_default"/>
|
||||||
</tree>
|
</tree>
|
||||||
</field>
|
</field>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
<!-- supplier info form view -->
|
<!-- supplier info form view -->
|
||||||
<record model="ir.ui.view" id="product_return_instructions_form_view">
|
<record model="ir.ui.view" id="product_return_instructions_form_view">
|
||||||
<field name="name">product.return.instructions.form</field>
|
<field name="name">product.return.instructions.form</field>
|
||||||
<field name="model">return.instruction</field>
|
<field name="model">return.instruction</field>
|
||||||
<field name="type">form</field>
|
<field name="type">form</field>
|
||||||
<field name="arch" type="xml">
|
<field name="arch" type="xml">
|
||||||
<form string="Return instructions">
|
<form string="Return instructions">
|
||||||
<field name="name"/>
|
<field name="name"/>
|
||||||
<field name="is_default"/>
|
<field name="is_default"/>
|
||||||
<separator string="Instructions" colspan="4"/>
|
<separator string="Instructions" colspan="4"/>
|
||||||
<field name="instructions" nolabel="1" colspan="4"/>
|
<field name="instructions" nolabel="1" colspan="4"/>
|
||||||
</form>
|
</form>
|
||||||
</field>
|
</field>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
<record id="product_return_instructions_action" model="ir.actions.act_window">
|
<record id="product_return_instructions_action" model="ir.actions.act_window">
|
||||||
<field name="name">Products return instructions</field>
|
<field name="name">Products return instructions</field>
|
||||||
@@ -60,42 +60,44 @@
|
|||||||
<field name="view_id" ref="product_return_instructions_tree_view"/>
|
<field name="view_id" ref="product_return_instructions_tree_view"/>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
<menuitem action="product_return_instructions_action"
|
<menuitem action="product_return_instructions_action"
|
||||||
groups="base.group_extended"
|
groups="base.group_extended"
|
||||||
id="menu_product_return_instructions_action"
|
id="menu_product_return_instructions_action"
|
||||||
parent="product.prod_config_main" sequence="3"/>
|
parent="product.prod_config_main" sequence="3"/>
|
||||||
<!-- supplier info -->
|
<!-- supplier info -->
|
||||||
<!-- supplier info tree view -->
|
<!-- supplier info tree view -->
|
||||||
<record model="ir.ui.view" id="product_supplierinfo_warranty_tree_view">
|
<record model="ir.ui.view" id="product_supplierinfo_warranty_tree_view">
|
||||||
<field name="name">product.supplierinfo.warranty.tree</field>
|
<field name="name">product.supplierinfo.warranty.tree</field>
|
||||||
<field name="model">product.supplierinfo</field>
|
<field name="model">product.supplierinfo</field>
|
||||||
<field name="inherit_id" ref="product.product_supplierinfo_tree_view" />
|
<field name="inherit_id" ref="product.product_supplierinfo_tree_view" />
|
||||||
<field name="type">tree</field>
|
<field name="type">tree</field>
|
||||||
<field name="arch" type="xml">
|
<field name="arch" type="xml">
|
||||||
<field position="after" name="delay">
|
<field position="after" name="delay">
|
||||||
<field name="warranty_duration"/>
|
<field name="warranty_duration"/>
|
||||||
<field name="warranty_return_partner"/>
|
<field name="warranty_return_partner"/>
|
||||||
<field name="active_supplier"/>
|
<field name="warranty_return_address"/>
|
||||||
<field name="return_instructions"/>
|
<field name="active_supplier"/>
|
||||||
</field>
|
<field name="return_instructions"/>
|
||||||
</field>
|
</field>
|
||||||
</record>
|
</field>
|
||||||
|
</record>
|
||||||
<!-- supplier info form view -->
|
|
||||||
<record model="ir.ui.view" id="product_supplierinfo_warranty_form_view">
|
<!-- supplier info form view -->
|
||||||
<field name="name">product.supplierinfo.warranty.form</field>
|
<record model="ir.ui.view" id="product_supplierinfo_warranty_form_view">
|
||||||
<field name="model">product.supplierinfo</field>
|
<field name="name">product.supplierinfo.warranty.form</field>
|
||||||
<field name="inherit_id" ref="product.product_supplierinfo_form_view" />
|
<field name="model">product.supplierinfo</field>
|
||||||
<field name="type">form</field>
|
<field name="inherit_id" ref="product.product_supplierinfo_form_view" />
|
||||||
<field name="arch" type="xml">
|
<field name="type">form</field>
|
||||||
<field position="after" name="delay">
|
<field name="arch" type="xml">
|
||||||
<field name="warranty_duration"/>
|
<field position="after" name="delay">
|
||||||
<field name="warranty_return_partner" readonly="0"/>
|
<field name="warranty_duration"/>
|
||||||
<field name="active_supplier"/>
|
<field name="warranty_return_partner" readonly="0"/>
|
||||||
<field name="return_instructions"/>
|
<field name="warranty_return_address"/>
|
||||||
</field>
|
<field name="active_supplier"/>
|
||||||
</field>
|
<field name="return_instructions"/>
|
||||||
</record>
|
</field>
|
||||||
|
</field>
|
||||||
|
</record>
|
||||||
|
|
||||||
</data>
|
</data>
|
||||||
</openerp>
|
</openerp>
|
||||||
|
|||||||
Reference in New Issue
Block a user