mirror of
https://github.com/OCA/rma.git
synced 2025-02-16 17:11:47 +02:00
[FIX] crm_claim.date is a datetime, error when a product has no supplier, in such case, returns the product to the company's address
This commit is contained in:
committed by
Maxime Chambreuil
parent
e7cc2e33ae
commit
4acafa0cbf
@@ -21,48 +21,54 @@
|
||||
#########################################################################
|
||||
|
||||
from openerp.osv import orm, fields
|
||||
from tools.translate import _
|
||||
|
||||
|
||||
class return_instruction(orm.Model):
|
||||
_name = "return.instruction"
|
||||
_description = "Instructions for product return"
|
||||
_columns = {
|
||||
'name': fields.char('Title', size=128, required=True),
|
||||
'instructions' : fields.text('Instructions',
|
||||
'name': fields.char('Title', required=True),
|
||||
'instructions': fields.text(
|
||||
'Instructions',
|
||||
help="Instructions for product return"),
|
||||
'is_default' : fields.boolean('Is default',
|
||||
'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"),
|
||||
}
|
||||
|
||||
|
||||
class product_supplierinfo(orm.Model):
|
||||
_inherit = "product.supplierinfo"
|
||||
|
||||
def get_warranty_return_partner(self, cr, uid, context=None):
|
||||
result = [
|
||||
('company','Company'),
|
||||
('supplier','Supplier'),
|
||||
('other','Other'),]
|
||||
result = [('company', 'Company'),
|
||||
('supplier', 'Supplier'),
|
||||
('other', 'Other'),
|
||||
]
|
||||
return result
|
||||
|
||||
# Get selected lines to add to exchange
|
||||
def _get_default_instructions(self, cr, uid, context=None):
|
||||
instruction_ids = self.pool.get('return.instruction').search(cr, uid,
|
||||
[('is_default','=','FALSE')])
|
||||
""" Get selected lines to add to exchange """
|
||||
instr_obj = self.pool.get('return.instruction')
|
||||
instruction_ids = instr_obj.search(cr, uid,
|
||||
[('is_default', '=', 'FALSE')],
|
||||
context=context)
|
||||
if instruction_ids:
|
||||
return instruction_ids[0]
|
||||
# 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')
|
||||
""" 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 = {}
|
||||
for supplier_info in self.browse(cr, uid, ids, context=context):
|
||||
result[supplier_info.id] = {}
|
||||
address_id = False
|
||||
result[supplier_info.id] = False
|
||||
return_partner = supplier_info.warranty_return_partner
|
||||
partner_id = supplier_info.company_id.partner_id.id
|
||||
if return_partner:
|
||||
@@ -78,11 +84,13 @@ class product_supplierinfo(orm.Model):
|
||||
return result
|
||||
|
||||
_columns = {
|
||||
"warranty_duration": fields.float('Period',
|
||||
"warranty_duration": fields.float(
|
||||
'Period',
|
||||
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,
|
||||
"warranty_return_partner": fields.selection(
|
||||
get_warranty_return_partner,
|
||||
'Return type',
|
||||
required=True,
|
||||
help="Who is in charge of the warranty return treatment toward the end customer. "
|
||||
@@ -90,21 +98,26 @@ class product_supplierinfo(orm.Model):
|
||||
"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',
|
||||
'return_instructions': fields.many2one(
|
||||
'return.instruction',
|
||||
'Instructions',
|
||||
help="Instructions for product return"),
|
||||
'active_supplier': fields.boolean('Active supplier',
|
||||
'active_supplier': fields.boolean(
|
||||
'Active supplier',
|
||||
help="Is this supplier still active, only for information"),
|
||||
'warranty_return_address': fields.function(_get_warranty_return_address,
|
||||
'warranty_return_address': fields.function(
|
||||
_get_warranty_return_address,
|
||||
type='many2one', relation='res.partner', string="Return address",
|
||||
help="Where the goods should be returned (computed field based on other infos.)"),
|
||||
"warranty_return_other_address_id" : fields.many2one('res.partner',
|
||||
help="Where the goods should be returned "
|
||||
"(computed field based on other infos.)"),
|
||||
"warranty_return_other_address_id": fields.many2one(
|
||||
'res.partner',
|
||||
'Return address',
|
||||
help="Where the customer has to send back the product(s) if warranty return is set"
|
||||
"to 'other'."),
|
||||
}
|
||||
_defaults = {
|
||||
'warranty_return_partner': lambda *a: 'company',
|
||||
'return_instructions': _get_default_instructions,
|
||||
help="Where the customer has to send back the product(s) "
|
||||
"if warranty return is set to 'other'."),
|
||||
}
|
||||
|
||||
_defaults = {
|
||||
'warranty_return_partner': 'company',
|
||||
'return_instructions': _get_default_instructions,
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
from openerp.osv import fields, orm, osv
|
||||
from openerp.osv import fields, orm
|
||||
|
||||
|
||||
class res_company(orm.Model):
|
||||
@@ -28,11 +28,10 @@ class res_company(orm.Model):
|
||||
_inherit = "res.company"
|
||||
|
||||
_columns = {
|
||||
'crm_return_address_id': fields.many2one('res.partner',
|
||||
'crm_return_address_id': fields.many2one(
|
||||
'res.partner',
|
||||
'Return address',
|
||||
help="Default address where the customers has to send back the "
|
||||
"returned product. If empty, the address is the "
|
||||
"company address"),
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user