[UPD] move auto_set_warranty method on claim.line model as suggested by Benoit Guillot

This commit is contained in:
Romain Deheele
2014-05-12 11:43:10 +02:00
parent b445a46734
commit 7dd8e06a07
2 changed files with 13 additions and 12 deletions

View File

@@ -254,6 +254,16 @@ class claim_line(orm.Model):
context=context)
return True
def auto_set_warranty(self, cr, uid, ids, context):
""" For each line, if the user has not himself pressed
on 'calculate warranty state', it sets warranty"""
if context is None:
context = {}
for line in self.browse(cr, uid, ids, context=context):
if not line.warning:
self.set_warranty(cr, uid, [line.id], context=context)
return True
def get_destination_location(self, cr, uid, product_id,
warehouse_id, context=None):
"""Compute and return the destination location ID to take

View File

@@ -106,17 +106,6 @@ class claim_make_picking(orm.TransientModel):
loc_id = line_location[0]
return loc_id
def _auto_set_warranty(self, cr, uid, line_ids, context):
""" For each line, if the user has not himself pressed
on 'calculate warranty state', it sets warranty"""
if context is None:
context = {}
line_obj = self.pool.get('claim.line')
for line in line_obj.browse(cr, uid, line_ids, context=context):
if not line.warning:
line_obj.set_warranty(cr, uid, [line.id], context=context)
return True
def _get_common_partner_from_line(self, cr, uid, line_ids, context):
"""Return the ID of the common partner between all lines. If no common
partner was found, return False"""
@@ -205,7 +194,9 @@ class claim_make_picking(orm.TransientModel):
_('A product return cannot be created for various '
'destination locations, please choose line with a '
'same destination location.'))
self._auto_set_warranty(cr, uid, line_ids, context=context)
self.pool.get('claim.line').auto_set_warranty(cr, uid,
line_ids,
context=context)
common_dest_partner_id = self._get_common_partner_from_line(
cr, uid, line_ids, context=context)
if not common_dest_partner_id: