← Back to team overview

openerp-community-reviewer team mailing list archive

[Merge] lp:~camptocamp/openerp-rma/7.0-crm_claim_rma_auto_set_warranty-rde into lp:openerp-rma

 

Romain Deheele - Camptocamp has proposed merging lp:~camptocamp/openerp-rma/7.0-crm_claim_rma_auto_set_warranty-rde into lp:openerp-rma.

Requested reviews:
  OpenERP RMA (openerprma)

For more details, see:
https://code.launchpad.net/~camptocamp/openerp-rma/7.0-crm_claim_rma_auto_set_warranty-rde/+merge/218666

Hello,

It adds a _auto_set_warranty function.
For each claim line, if the user has not pressed himself on 'calculate warranty state', it sets warranties automatically for him.

Regards,

Romain
-- 
https://code.launchpad.net/~camptocamp/openerp-rma/7.0-crm_claim_rma_auto_set_warranty-rde/+merge/218666
Your team OpenERP RMA is requested to review the proposed merge of lp:~camptocamp/openerp-rma/7.0-crm_claim_rma_auto_set_warranty-rde into lp:openerp-rma.
=== modified file 'crm_claim_rma/wizard/claim_make_picking.py'
--- crm_claim_rma/wizard/claim_make_picking.py	2014-04-08 19:41:50 +0000
+++ crm_claim_rma/wizard/claim_make_picking.py	2014-05-07 16:52:49 +0000
@@ -106,6 +106,17 @@
             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"""
@@ -194,6 +205,7 @@
                     _('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)
             common_dest_partner_id = self._get_common_partner_from_line(
                 cr, uid, line_ids, context=context)
             if not common_dest_partner_id:


Follow ups