← Back to team overview

openerp-community-reviewer team mailing list archive

[Merge] lp:~akretion-team/openerp-rma/rma-cleanup-cleanup-cleanup into lp:openerp-rma

 

Alexis de Lattre has proposed merging lp:~akretion-team/openerp-rma/rma-cleanup-cleanup-cleanup into lp:openerp-rma.

Requested reviews:
  OpenERP RMA (openerprma)

For more details, see:
https://code.launchpad.net/~akretion-team/openerp-rma/rma-cleanup-cleanup-cleanup/+merge/215970

The main changes of this MPs are :

1) Create 2 groups for RMA : User and Manager (by default, RMAs i.e. crm.claim can be used by salesman... but do you know a company where RMAs are handled by salesman ??)

2) Clean-up presentation in copyright headers and update licence to AGPL when needed

3) Update views to v7.0 style

4) CLEAN UP CODE (and there is still A LOT to do in this area ! A LOT !). Remove dead code. I mean, this project, in the current state of the code, doesn't deserve to be an OCA project and doesn't meet the quality standards of OCA. This is just a start to try and clean a number of dirty stuff, but there is still a lot to do in this area. For example, a number of fields should be renamed, but this would have to be done in another merge proposal (I haven't changed any field name in this MP).

5) Small changes to prepare the arrival of the modules crm_claim_rma_repair, crm_claim_rma_serial and product_serial_warranty (will be part of another MP)
-- 
https://code.launchpad.net/~akretion-team/openerp-rma/rma-cleanup-cleanup-cleanup/+merge/215970
Your team OpenERP RMA is requested to review the proposed merge of lp:~akretion-team/openerp-rma/rma-cleanup-cleanup-cleanup into lp:openerp-rma.
=== modified file 'crm_claim_rma/__openerp__.py'
--- crm_claim_rma/__openerp__.py	2013-12-12 15:26:26 +0000
+++ crm_claim_rma/__openerp__.py	2014-04-15 21:39:34 +0000
@@ -74,6 +74,7 @@
                 ],
     'data': ['wizard/claim_make_picking_view.xml',
              'crm_claim_rma_view.xml',
+             'security/rma_group.xml',
              'security/ir.model.access.csv',
              'account_invoice_view.xml',
              'stock_view.xml',

=== modified file 'crm_claim_rma/crm_claim_rma.py'
--- crm_claim_rma/crm_claim_rma.py	2013-12-03 10:38:43 +0000
+++ crm_claim_rma/crm_claim_rma.py	2014-04-15 21:39:34 +0000
@@ -1,8 +1,8 @@
 # -*- coding: utf-8 -*-
 ##############################################################################
 #
-#    Copyright 2013 Camptocamp
-#    Copyright 2009-2013 Akretion,
+#    Copyright 2013-2014 Camptocamp
+#    Copyright 2009-2014 Akretion,
 #    Author: Emmanuel Samyn, Raphaël Valyi, Sébastien Beau,
 #            Benoît Guillot, Joel Grand-Guillaume
 #
@@ -21,8 +21,6 @@
 #
 ##############################################################################
 
-import calendar
-import math
 from openerp.osv import fields, orm
 from datetime import datetime
 from dateutil.relativedelta import relativedelta
@@ -36,7 +34,7 @@
     _name = "substate.substate"
     _description = "substate that precise a given state"
     _columns = {
-        'name': fields.char('Sub state', required=True),
+        'name': fields.char('Sub State', required=True),
         'substate_descr': fields.text(
             'Description',
             help="To give more information about the sub state"),
@@ -50,11 +48,41 @@
     _name = "claim.line"
     _description = "List of product to return"
 
-    # Comment written in a claim.line to know about the warranty status
-    WARRANT_COMMENT = {
-        'valid': "Valid",
-        'expired': "Expired",
-        'not_define': "Not Defined"}
+    def prodlot_id_change(
+            self, cr, uid, ids, prodlot_id, company_id, warehouse_id,
+            context=None):
+        res = {'value': {}}
+        if prodlot_id:
+            prodlot = self.pool['stock.production.lot'].browse(
+                cr, uid, prodlot_id, context=context)
+            return_address_id, return_type = \
+                self.pool['crm.claim']._get_return_info_from_product(
+                    cr, uid, prodlot.product_id, company_id,
+                    context=context)
+
+            res['value'].update({
+                'product_id': prodlot.product_id.id,
+                'product_returned_quantity': 1,
+                'return_address_id': return_address_id,
+                'return_type': return_type,
+                })
+        else:
+            res['value'].update({
+                'product_id': False,
+                'product_returned_quantity': 0,
+                'return_address_id': False,
+                'return_type': False,
+                })
+        return res
+
+    def product_id_change(
+            self, cr, uid, ids, product_id, company_id, context=None):
+        res = {'domain': {}}
+        if product_id:
+            res['domain']['prodlot_id'] = "[('product_id', '=', product_id)]"
+        else:
+            res['domain']['prodlot_id'] = "[]"
+        return res
 
     # Method to calculate total amount of the line : qty*UP
     def _line_total_amount(self, cr, uid, ids, field_name, arg, context=None):
@@ -117,8 +145,8 @@
             help="Quantity returned * Unit sold price",),
         'prodlot_id': fields.many2one(
             'stock.production.lot',
-            string='Serial/Lot n°',
-            help="The serial/lot of the returned product"),
+            string='Serial Number',
+            help="The serial number of the returned product"),
         'applicable_guarantee': fields.selection(
             [('us', 'Company'),
              ('supplier', 'Supplier'),
@@ -126,17 +154,17 @@
             'Warranty type'),
         'guarantee_limit': fields.date(
             'Warranty limit',
-            readonly=True,
             help="The warranty limit is computed as: invoice date + warranty "
                  "defined on selected product."),
-        'warning': fields.char(
-            'Warranty',
-            readonly=True,
+        'warning': fields.selection([
+            ('valid', "Valid"),
+            ('expired', "Expired"),
+            ('not_define', "Not Defined"),
+        ], 'Warranty',
             help="If warranty has expired"),
         "warranty_type":  fields.selection(
             get_warranty_return_partner,
             'Warranty type',
-            readonly=True,
             help="Who is in charge of the warranty return treatment towards the end customer. "
                  "Company will use the current company delivery or default address and so on for "
                  "supplier and brand manufacturer. Does not necessarily mean that the warranty to be "
@@ -149,6 +177,9 @@
         'claim_id': fields.many2one(
             'crm.claim', string='Related claim',
             help="To link to the case.claim object"),
+        'company_id': fields.related(
+            'claim_id', 'company_id', type="many2one",
+            relation="res.company", string="Company"),
         'state' : fields.selection(
             [('draft', 'Draft'),
              ('refused', 'Refused'),
@@ -194,63 +225,6 @@
         'name': 'none',
     }
 
-    @staticmethod
-    def warranty_limit(start, warranty_duration):
-        """ Take a duration in float, return the duration in relativedelta
-
-        ``relative_delta(months=...)`` only accepts integers.
-        We have to extract the decimal part, and then, extend the delta with
-        days.
-
-        """
-        decimal_part, months = math.modf(warranty_duration)
-        months = int(months)
-        # If we have a decimal part, we add the number them as days to
-        # the limit.  We need to get the month to know the number of
-        # days.
-        delta = relativedelta(months=months)
-        monthday = start + delta
-        __, days_month = calendar.monthrange(monthday.year, monthday.month)
-        # ignore the rest of the days (hours) since we expect a date
-        days = int(days_month * decimal_part)
-        return start + relativedelta(months=months, days=days)
-
-    # Method to calculate warranty limit
-    def set_warranty_limit(self, cr, uid, ids, claim_line, context=None):
-        date_invoice = claim_line.invoice_line_id.invoice_id.date_invoice
-        if not date_invoice:
-            raise orm.except_orm(
-                _('Error'),
-                _('Cannot find any date for invoice. '
-                  'Must be a validated invoice.'))
-        warning = _(self.WARRANT_COMMENT['not_define'])
-        date_inv_at_server = datetime.strptime(date_invoice,
-                                               DEFAULT_SERVER_DATE_FORMAT)
-        if claim_line.claim_id.claim_type == 'supplier':
-            suppliers = claim_line.product_id.seller_ids
-            if not suppliers:
-                raise orm.except_orm(
-                    _('Error'),
-                    _('The product has no supplier configured.'))
-            supplier = suppliers[0]
-            warranty_duration = supplier.warranty_duration
-        else:
-            warranty_duration = claim_line.product_id.warranty
-        limit = self.warranty_limit(date_inv_at_server, warranty_duration)
-        # If waranty period was defined
-        if warranty_duration > 0:
-            claim_date = datetime.strptime(claim_line.claim_id.date,
-                                           DEFAULT_SERVER_DATETIME_FORMAT)
-            if limit < claim_date:
-                warning = _(self.WARRANT_COMMENT['expired'])
-            else:
-                warning = _(self.WARRANT_COMMENT['valid'])
-        self.write(cr, uid, ids,
-                   {'guarantee_limit': limit.strftime(DEFAULT_SERVER_DATE_FORMAT),
-                    'warning': warning},
-                   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
@@ -269,101 +243,34 @@
                     location_dest_id = seller.name.property_stock_supplier.id
         return location_dest_id
 
-    # Method to calculate warranty return address
-    def set_warranty_return_address(self, cr, uid, ids, claim_line, context=None):
-        """Return the partner to be used as return destination and
-        the destination stock location of the line in case of return.
-
-        We can have various case here:
-            - company or other: return to company partner or crm_return_address_id
-              if specified
-            - supplier: return to the supplier address
-
-        """
-        return_address = None
-        seller = claim_line.product_id.seller_info_id
-        if seller:
-            return_address_id = seller.warranty_return_address.id
-            return_type = seller.warranty_return_partner
-        else:
-            # when no supplier is configured, returns to the company
-            company = claim_line.claim_id.company_id
-            return_address = (company.crm_return_address_id or
-                              company.partner_id)
-            return_address_id = return_address.id
-            return_type = 'company'
-
-        location_dest_id = self.get_destination_location(
-            cr, uid, claim_line.product_id.id,
-            claim_line.claim_id.warehouse_id.id,
-            context=context)
-        self.write(cr, uid, ids,
-                   {'warranty_return_partner': return_address_id,
-                    'warranty_type': return_type,
-                    'location_dest_id': location_dest_id},
-                   context=context)
-        return True
-
-    def set_warranty(self, cr, uid, ids, context=None):
-        """ Calculate warranty limit and address """
-        for claim_line in self.browse(cr, uid, ids, context=context):
-            if not (claim_line.product_id and claim_line.invoice_line_id):
-                raise orm.except_orm(
-                    _('Error !'),
-                    _('Please set product and invoice.'))
-            self.set_warranty_limit(cr, uid, ids,
-                                    claim_line, context=context)
-            self.set_warranty_return_address(cr, uid, ids,
-                                             claim_line, context=context)
-        return True
-
 
 #TODO add the option to split the claim_line in order to manage the same product separately
 class crm_claim(orm.Model):
     _inherit = 'crm.claim'
-
-    def _get_sequence_number(self, cr, uid, context=None):
-        seq_obj = self.pool.get('ir.sequence')
-        res = seq_obj.get(cr, uid, 'crm.claim.rma', context=context) or '/'
-        return res
+    _order = 'number desc'
 
     def _get_default_warehouse(self, cr, uid, context=None):
-        user_obj = self.pool.get('res.users')
-        user = user_obj.browse(cr, uid, uid, context=context)
-        company_id = user.company_id.id
-        wh_obj = self.pool.get('stock.warehouse')
-        wh_ids = wh_obj.search(cr, uid,
-                               [('company_id', '=', company_id)],
-                               context=context)
-        if not wh_ids:
-            raise orm.except_orm(
-                _('Error!'),
-                _('There is no warehouse for the current user\'s company.'))
-        return wh_ids[0]
+        warehouse_model, warehouse_id = self.pool['ir.model.data'].\
+        get_object_reference(cr, uid, 'stock', 'warehouse0')
+        assert warehouse_model == 'stock.warehouse', 'Wrong model !'
+        return warehouse_id
 
     def name_get(self, cr, uid, ids, context=None):
         res = []
         for claim in self.browse(cr, uid, ids, context=context):
-            res.append((claim.id, '[' + claim.number + '] ' + claim.name))
+            res.append((claim.id, '[%s] %s' % (claim.number, claim.name)))
         return res
 
-    def create(self, cr, uid, vals, context=None):
-        if ('number' not in vals) or (vals.get('number') == '/'):
-            vals['number'] = self._get_sequence_number(cr, uid, context=context)
-        new_id = super(crm_claim, self).create(cr, uid, vals, context=context)
-        return new_id
-
-    def copy_data(self, cr, uid, id, default=None, context=None):
+    def copy(self, cr, uid, id, default=None, context=None):
         if default is None:
             default = {}
-        std_default = {
+        default.update({
             'invoice_ids': False,
             'picking_ids': False,
-            'number': self._get_sequence_number(cr, uid, context=context),
-        }
-        std_default.update(default)
-        return super(crm_claim, self).copy_data(
-            cr, uid, id, default=std_default, context=context)
+            'number': self.pool['ir.sequence'].get(cr, uid, 'crm.claim.rma'),
+        })
+        return super(crm_claim, self).copy(
+            cr, uid, id, default=default, context=context)
 
     _columns = {
         'number': fields.char(
@@ -390,15 +297,15 @@
         'invoice_ids': fields.one2many('account.invoice', 'claim_id', 'Refunds'),
         'picking_ids': fields.one2many('stock.picking', 'claim_id', 'RMA'),
         'invoice_id': fields.many2one(
-            'account.invoice', string='Invoice',
-            help='Related original Cusotmer invoice'),
+            'account.invoice', string='Customer Invoice',
+            help='Related original Customer invoice'),
         'warehouse_id': fields.many2one(
             'stock.warehouse', string='Warehouse',
             required=True),
     }
 
     _defaults = {
-        'number': '/',
+        'number': lambda self, cr, uid, context: self.pool['ir.sequence'].get(cr, uid, 'crm.claim.rma'),
         'claim_type': 'customer',
         'warehouse_id': _get_default_warehouse,
     }
@@ -408,7 +315,26 @@
          'Number/Reference must be unique per Company!'),
     ]
 
-    def onchange_partner_address_id(self, cr, uid, ids, add, email=False, context=None):
+    def _get_return_info_from_product(
+            self, cr, uid, product, company_id, context=None):
+        seller = product.seller_info_id
+        if seller:
+            return_address_id = seller.warranty_return_address.id
+            return_type = seller.warranty_return_partner
+        else:
+            # when no supplier is configured, get the info from the company
+            if not company_id:
+                company_id = self.pool['res.company']._company_default_get(
+                    cr, uid, 'claim.line', context=context)
+            company = self.pool['res.company'].browse(
+                cr, uid, company_id, context=context)
+            return_address_id = (company.crm_return_address_id.id or
+                              company.partner_id.id)
+            return_type = 'company'
+        return (return_address_id, return_type)
+
+    def onchange_partner_address_id(
+            self, cr, uid, ids, add, email=False, context=None):
         res = super(crm_claim, self).onchange_partner_address_id(
             cr, uid, ids, add, email=email)
         if add:
@@ -422,22 +348,51 @@
                         res['value']['partner_phone'] = other_add.phone
         return res
 
-    def onchange_invoice_id(self, cr, uid, ids, invoice_id, warehouse_id, context=None):
+    def onchange_invoice_id(
+            self, cr, uid, ids, invoice_id, warehouse_id, claim_date,
+            company_id, context=None):
         invoice_line_obj = self.pool.get('account.invoice.line')
         claim_line_obj = self.pool.get('claim.line')
-        invoice_line_ids = invoice_line_obj.search(
-            cr, uid,
-            [('invoice_id', '=', invoice_id)],
-            context=context)
+        if not invoice_id:
+            return {}
+        invoice = self.pool['account.invoice'].browse(
+            cr, uid, invoice_id, context=context)
+
+        if not invoice.date_invoice:
+            raise orm.except_orm(
+                _('Error'),
+                _("The invoice %s doesn't have a date. "
+                  "Must be a validated invoice." % invoice.number))
+        date_inv_dt = datetime.strptime(
+            invoice.date_invoice, DEFAULT_SERVER_DATE_FORMAT)
+
         claim_lines = []
         if not warehouse_id:
-            warehouse_id = self._get_default_warehouse(cr, uid, context=context)
-        invoice_lines = invoice_line_obj.browse(cr, uid, invoice_line_ids,
-                                                context=context)
-        for invoice_line in invoice_lines:
+            warehouse_id = self._get_default_warehouse(
+                cr, uid, context=context)
+
+        for invoice_line in invoice.invoice_line:
             location_dest_id = claim_line_obj.get_destination_location(
                 cr, uid, invoice_line.product_id.id,
                 warehouse_id, context=context)
+
+            warning = 'not_define'
+            warranty_duration = invoice_line.product_id.warranty
+            limit = self.pool['product.product'].warranty_limit(
+                cr, uid, date_inv_dt, warranty_duration, context=context)
+            # If warranty period was defined
+            if warranty_duration > 0:
+                claim_date_dt = datetime.strptime(
+                    claim_date, DEFAULT_SERVER_DATETIME_FORMAT)
+                if limit < claim_date_dt:
+                    warning = 'expired'
+                else:
+                    warning = 'valid'
+
+            return_address_id, return_type = \
+                self._get_return_info_from_product(
+                    cr, uid, product, company_id, context=context)
+
             claim_lines.append({
                 'name': invoice_line.name,
                 'claim_origine': "none",
@@ -447,5 +402,9 @@
                 'unit_sale_price': invoice_line.price_unit,
                 'location_dest_id': location_dest_id,
                 'state': 'draft',
+                'warranty_return_partner': return_address_id,
+                'warranty_type': return_type,
+                'guarantee_limit': limit.strftime(DEFAULT_SERVER_DATE_FORMAT),
+                'warning': warning,
             })
         return {'value': {'claim_line_ids': claim_lines}}

=== modified file 'crm_claim_rma/crm_claim_rma_data.xml'
--- crm_claim_rma/crm_claim_rma_data.xml	2013-04-30 19:15:31 +0000
+++ crm_claim_rma/crm_claim_rma_data.xml	2014-04-15 21:39:34 +0000
@@ -1,104 +1,96 @@
 <?xml version="1.0"?>
 <openerp>
-    <data noupdate="1">
-	<!-- Claims Sequence n° -->
-	<record id="seq_type_claim" model="ir.sequence.type">
-            <field name="name">CRM Claim</field>
-            <field name="code">crm.claim.rma</field>
-        </record>
-
-        <record id="seq_claim" model="ir.sequence">
-            <field name="name">CRM Claim</field>
-            <field name="code">crm.claim.rma</field>
-            <field eval="5" name="padding"/>
-            <field name="prefix">RMA-%(year)s/</field>
-        </record>
-	
-        <!--
-	    Claim sections
-        -->
-	
-	<record model="crm.case.section" id="section_after_sales_service">
-            <field name="name">After Sales Service</field>
-            <field name="code">ASV</field>
-            <field name="parent_id" ref="crm.section_sales_department"/>
-            <!-- <field name="stage_ids" eval="[(4, ref('crm_claim.stage_claim1')), (4, ref('crm_claim.stage_claim2')), (4, ref('crm_claim.stage_claim3')), (4, ref('crm_claim.stage_claim5'))]"/> -->
-        </record>
-		
-        <!--
-	    Claim categories
-        -->
-	
-	<record model="crm.case.categ" id="categ_claim10">
-            <field name="name">No Inventory</field>
-            <field name="section_id" ref="section_after_sales_service"/>
-            <field name="object_id" search="[('model','=','crm.claim')]" model="ir.model"/> 
-        </record>
-	
-	<record model="crm.case.categ" id="categ_claim11">
-            <field name="name">Customer Return</field>
-            <field name="section_id" ref="section_after_sales_service"/>
-            <field name="object_id" search="[('model','=','crm.claim')]" model="ir.model"/> 
-        </record>
-	
-	<record model="crm.case.categ" id="categ_claim12">
-            <field name="name">Buyer Cancelled</field>
-            <field name="section_id" ref="section_after_sales_service"/>
-            <field name="object_id" search="[('model','=','crm.claim')]" model="ir.model"/> 
-        </record>
-	
-	<record model="crm.case.categ" id="categ_claim13">
-            <field name="name">General Adjustement</field>
-            <field name="section_id" ref="section_after_sales_service"/>
-            <field name="object_id" search="[('model','=','crm.claim')]" model="ir.model"/> 
-        </record>
-	
-	<record model="crm.case.categ" id="categ_claim14">
-            <field name="name">Could Not Ship</field>
-            <field name="section_id" ref="section_after_sales_service"/>
-            <field name="object_id" search="[('model','=','crm.claim')]" model="ir.model"/> 
-        </record>
-	
-	<record model="crm.case.categ" id="categ_claim15">
-            <field name="name">Different Item</field>
-            <field name="section_id" ref="section_after_sales_service"/>
-            <field name="object_id" search="[('model','=','crm.claim')]" model="ir.model"/> 
-        </record>
-	
-	<record model="crm.case.categ" id="categ_claim16">
-            <field name="name">Merchandise Not Received</field>
-            <field name="section_id" ref="section_after_sales_service"/>
-            <field name="object_id" search="[('model','=','crm.claim')]" model="ir.model"/> 
-        </record>
-	
-	<record model="crm.case.categ" id="categ_claim17">
-            <field name="name">Merchandise Not As Described</field>
-            <field name="section_id" ref="section_after_sales_service"/>
-            <field name="object_id" search="[('model','=','crm.claim')]" model="ir.model"/> 
-        </record>
-	
-	<record model="crm.case.categ" id="categ_claim18">
-            <field name="name">Pricing Error</field>
-            <field name="section_id" ref="section_after_sales_service"/>
-            <field name="object_id" search="[('model','=','crm.claim')]" model="ir.model"/> 
-        </record>
-	
-	<record model="crm.case.categ" id="categ_claim19">
-            <field name="name">Shipping Address Undeliverable</field>
-            <field name="section_id" ref="section_after_sales_service"/>
-            <field name="object_id" search="[('model','=','crm.claim')]" model="ir.model"/> 
-        </record>
-	
-	<record model="crm.case.categ" id="categ_claim20">
-            <field name="name">Delivered Late by Carrier</field>
-            <field name="section_id" ref="section_after_sales_service"/>
-            <field name="object_id" search="[('model','=','crm.claim')]" model="ir.model"/> 
-        </record>
-
-	<record model="crm.case.categ" id="categ_claim21">
-            <field name="name">Missed Fulfilment Promise</field>
-            <field name="section_id" ref="section_after_sales_service"/>
-            <field name="object_id" search="[('model','=','crm.claim')]" model="ir.model"/> 
-        </record>
-    </data>
+<data noupdate="1">
+
+<!-- Claims Sequence n° -->
+<record id="seq_type_claim" model="ir.sequence.type">
+    <field name="name">CRM Claim</field>
+    <field name="code">crm.claim.rma</field>
+</record>
+
+<record id="seq_claim" model="ir.sequence">
+    <field name="name">CRM Claim</field>
+    <field name="code">crm.claim.rma</field>
+    <field name="padding" eval="5"/>
+    <field name="prefix">RMA-%(year)s/</field>
+</record>
+
+<!-- Claim sections  -->
+
+<record model="crm.case.section" id="section_after_sales_service">
+    <field name="name">After Sales Service</field>
+    <field name="code">ASV</field>
+    <field name="parent_id" ref="crm.section_sales_department"/>
+</record>
+
+<!--  Claim categories -->
+
+<record model="crm.case.categ" id="categ_claim10">
+    <field name="name">No Inventory</field>
+    <field name="section_id" ref="section_after_sales_service"/>
+    <field name="object_id" search="[('model','=','crm.claim')]" model="ir.model"/>
+</record>
+
+<record model="crm.case.categ" id="categ_claim11">
+    <field name="name">Customer Return</field>
+    <field name="section_id" ref="section_after_sales_service"/>
+    <field name="object_id" search="[('model','=','crm.claim')]" model="ir.model"/>
+</record>
+
+<record model="crm.case.categ" id="categ_claim12">
+    <field name="name">Cancelled by Customer</field>
+    <field name="section_id" ref="section_after_sales_service"/>
+    <field name="object_id" search="[('model','=','crm.claim')]" model="ir.model"/>
+</record>
+
+<record model="crm.case.categ" id="categ_claim13">
+    <field name="name">General Adjustement</field>
+    <field name="section_id" ref="section_after_sales_service"/>
+    <field name="object_id" search="[('model','=','crm.claim')]" model="ir.model"/>
+</record>
+
+<record model="crm.case.categ" id="categ_claim14">
+    <field name="name">Could Not Ship</field>
+    <field name="section_id" ref="section_after_sales_service"/>
+    <field name="object_id" search="[('model','=','crm.claim')]" model="ir.model"/>
+</record>
+
+<record model="crm.case.categ" id="categ_claim15">
+    <field name="name">Different Item</field>
+    <field name="section_id" ref="section_after_sales_service"/>
+    <field name="object_id" search="[('model','=','crm.claim')]" model="ir.model"/>
+</record>
+
+<record model="crm.case.categ" id="categ_claim16">
+    <field name="name">Merchandise Not Received</field>
+    <field name="section_id" ref="section_after_sales_service"/>
+    <field name="object_id" search="[('model','=','crm.claim')]" model="ir.model"/>
+</record>
+
+<record model="crm.case.categ" id="categ_claim17">
+    <field name="name">Merchandise Not As Described</field>
+    <field name="section_id" ref="section_after_sales_service"/>
+    <field name="object_id" search="[('model','=','crm.claim')]" model="ir.model"/>
+</record>
+
+<record model="crm.case.categ" id="categ_claim18">
+    <field name="name">Price Error</field>
+    <field name="section_id" ref="section_after_sales_service"/>
+    <field name="object_id" search="[('model','=','crm.claim')]" model="ir.model"/>
+</record>
+
+<record model="crm.case.categ" id="categ_claim19">
+    <field name="name">Shipping Address Undeliverable</field>
+    <field name="section_id" ref="section_after_sales_service"/>
+    <field name="object_id" search="[('model','=','crm.claim')]" model="ir.model"/>
+</record>
+
+<record model="crm.case.categ" id="categ_claim20">
+    <field name="name">Delivered Late by Carrier</field>
+    <field name="section_id" ref="section_after_sales_service"/>
+    <field name="object_id" search="[('model','=','crm.claim')]" model="ir.model"/>
+</record>
+
+
+</data>
 </openerp>

=== modified file 'crm_claim_rma/crm_claim_rma_view.xml'
--- crm_claim_rma/crm_claim_rma_view.xml	2013-12-13 12:45:43 +0000
+++ crm_claim_rma/crm_claim_rma_view.xml	2014-04-15 21:39:34 +0000
@@ -7,42 +7,29 @@
             <field name="name">CRM - Claims Search</field>
             <field name="model">claim.line</field>
             <field name="arch" type="xml">
-                <search string="Search Claims">
-                    <filter icon="terp-check" string="Current" name="current"
-                        domain="[('state','in',('draft', 'refused', 'treated'))]"
-                        separator="1" help="Draft and Open Claims" />
-                    <filter icon="terp-camera_test"
-                        string="In Progress"
-                        domain="[('state','in',('confirmed','in_to_control','in_to_treate'))]"
-                        separator="1" help="In Progress Claims"/>
-                    <separator orientation="vertical"/>
-                    <field name="state" select='1'/>
-                    <field name="substate_id" select='1'/>
-                    <field name="name" select='1'/>
-                    <field name="warning" select='1'/>
-                    <field name="invoice_line_id" select='1'/>
-                    <field name="product_id" select='1'/>
-                    <field name="prodlot_id" select='1'/>
-                    <newline/>
-                    <group expand="0" string="More">
-                        <field name="last_state_change" select='1'/>
-                        <field name="guarantee_limit" select='1'/>
-                        <field name="return_value" select='1'/>    
-                        <field name="name" select='1'/>
-                    </group>
-                    <newline/>
-                    <group expand="0" string="Group By...">
-                        <filter string="Invoice" icon="terp-dolar"
-                            domain="[]" help="Invoice"
+                <search string="Search Return Lines">
+                    <filter string="Current" name="current"
+                        domain="[('state', 'in', ('draft', 'refused', 'treated'))]"
+                        help="Draft and Open Return Lines" />
+                    <filter string="In Progress" name="in_progress"
+                        domain="[('state', 'in', ('confirmed', 'in_to_control', 'in_to_treate'))]"
+                        help="Return Lines In Progress"/>
+                    <field name="state"/>
+                    <field name="substate_id"/>
+                    <field name="name"/>
+                    <field name="warning"/>
+                    <field name="invoice_line_id"/>
+                    <field name="product_id"/>
+                    <field name="prodlot_id"/>
+                    <group string="Group By..." name="group_by">
+                        <filter string="Invoice"
                             context="{'group_by':'invoice_id'}" />
-                        <filter string="Product" icon="terp-product"
-                            domain="[]" help="Product"
+                        <filter string="Product"
                             context="{'group_by':'product_id'}" />
-                        <separator orientation="vertical"/>
-                        <filter string="Substate" icon="terp-stage"
-                            domain="[]" context="{'group_by':'substate_id'}" />
-                        <filter string="Claim n°" icon="terp-emblem-documents"
-                            domain="[]" context="{'group_by':'claim_id'}" />
+                        <filter string="Substate"
+                            context="{'group_by':'substate_id'}" />
+                        <filter string="Claim n°"
+                            context="{'group_by':'claim_id'}" />
                     </group>
                 </search>
             </field>
@@ -54,16 +41,15 @@
             <field name="model">claim.line</field>
             <field name="arch" type="xml">
                 <tree string="Returned lines">
-                    <field name="claim_id" invisible="1"/>
+                    <field name="claim_id" invisible="not context.get('claim_line_main_view')"/>
                     <field name="state"/>
                     <field name="substate_id"/>
                     <field name="product_id"/>
                     <field name="name"/>
                     <field name="prodlot_id"/>
-                    <field name="warning"/> 
-                    <field name="warranty_type"/> 
-                    <field name="warranty_return_partner"/> 
-                    <button name="set_warranty" string="Compute Waranty" type="object" icon="gtk-justify-fill"/>
+                    <field name="warning"/>
+                    <field name="warranty_type"/>
+                    <field name="warranty_return_partner"/>
                     <field name="product_returned_quantity"/>
                     <field name="claim_origine"/>
                     <field name="refund_line_id"/>
@@ -79,52 +65,50 @@
             <field name="model">claim.line</field>
             <field name="arch" type="xml">
                 <form string="Claim Line" version="7.0">
-                <header>
-                    <button name="set_warranty" string="Calculate warranty state" type="object" class="oe_highlight"/>
-                </header>
-                <sheet string="Claims">
-                    <div class="oe_title">
+                    <sheet string="Claims">
+                        <div class="oe_title">
                             <group>
                                 <label for="name" class="oe_edit_only"/>
                                 <h1><field name="name"/></h1>
                             </group>
-                    </div>
-                    <group>
-                        <group string="Returned good">
-                            <field name="product_returned_quantity"/>
-                            <field name="product_id"/> 
-                            <field name="prodlot_id"/>
-                            <field name="unit_sale_price"/>
-                            <field name="return_value"/>
-                        </group>
-                        <group string="Linked Document">
-                            <field name="claim_id" />
-                            <field name="invoice_line_id"/>
-                            <field name="refund_line_id"/>
-                            <field name="move_in_id"/>
-                            <field name="move_out_id"/>
-                        </group>
-                    </group>
-                    <group>
-                        <group string="Problem">
-                            <field name="claim_origine" nolabel="1" colspan="4"/>
-                            <field name="claim_descr" nolabel="1" colspan="4"/>
-                        </group>
-                        <group string="Warranty">
-                            <field name="guarantee_limit"/>
-                            <field name="warning"/>
-                            <field name="warranty_return_partner"/>
-                            <field name="warranty_type"/>
-                        </group>
-                    </group>
-                    <separator string="State" colspan="4"/>
-                    <group col="6" colspan="4">
-                        <field name="state"/>
-                        <field name="substate_id" widget='selection' />
-                        <field name="last_state_change"/>
-                    </group>
-                </sheet>
-            </form>
+                        </div>
+                        <group>
+                            <group string="Returned good">
+                                <field name="product_returned_quantity"/>
+                                <field name="product_id" on_change="product_id_change(product_id, company_id, context)"/>
+                                <field name="prodlot_id" on_change="prodlot_id_change(prodlot_id, company_id, parent.warehouse_id, context)"/>
+                                <field name="unit_sale_price"/>
+                                <field name="return_value"/>
+                            </group>
+                            <group string="Linked Document">
+                                <field name="claim_id" invisible="not context.get('claim_line_main_view')"/>
+                                <field name="company_id" groups="base.group_multi_company"/>
+                                <field name="invoice_line_id"/>
+                                <field name="refund_line_id"/>
+                                <field name="move_in_id"/>
+                                <field name="move_out_id"/>
+                            </group>
+                        </group>
+                        <group>
+                            <group string="Problem">
+                                <field name="claim_origine" nolabel="1" colspan="2"/>
+                                <field name="claim_descr" nolabel="1" colspan="2"/>
+                            </group>
+                            <group string="Warranty">
+                                <field name="guarantee_limit"/>
+                                <field name="warning"/>
+                                <field name="warranty_return_partner"/>
+                                <field name="warranty_type"/>
+                            </group>
+                        <group name="state" string="State">
+                            <field name="state"/>
+                            <field name="substate_id" widget="selection" />
+                            <field name="location_dest_id"/>
+                            <field name="last_state_change"/>
+                        </group>
+                        </group>
+                    </sheet>
+                </form>
             </field>
         </record>
 
@@ -144,36 +128,38 @@
         </field>
     </record>
 
-    <record model="ir.ui.view" id="crm_case_claims_form_view_replace">
-            <field name="name">CRM - Claims Form</field>
-            <field name="model">crm.claim</field>
-            <field name="inherit_id" ref="crm_claim.crm_case_claims_form_view"/>
-            <field name="arch" type="xml">
-                <field name="categ_id" widget="selection" domain="[('object_id.model', '=', 'crm.claim')]" position="replace">
-                    <field name="categ_id" />
-                </field>
-            </field>
-        </record>
-
-    <record model="ir.ui.view" id="crm_claim_rma_form_view">
-        <field name="name">CRM - Claim product return Form</field>
+    <record id="crm_case_claims_form_view" model="ir.ui.view">
+        <field name="name">CRM RMA - Claims Form</field>
         <field name="model">crm.claim</field>
         <field name="inherit_id" ref="crm_claim.crm_case_claims_form_view"/>
         <field name="arch" type="xml">
-            <page string="Follow Up" position="before">
+            <xpath expr="//sheet/group" position="before">
+                <group name="number">
+                    <div class="oe_title">
+                        <label for="number" class="oe_edit_only"/>
+                        <h1><field name="number"/></h1>
+                    </div>
+                </group>
+            </xpath>
+            <field name="date_deadline" position="after">
+                <field name="claim_type"/>
+                <field name="warehouse_id" />
+            </field>
+            <field name="categ_id" widget="selection" domain="[('object_id.model', '=', 'crm.claim')]" position="replace">
+                <field name="categ_id" />
+            </field>
+            <notebook position="inside">
                 <page string="Product Return">
-                    <group name="Product Return">
-                        <separator string="Product Return" colspan="4"/>
+                    <group name="Product Return" string="Product Returns">
                         <group>
-                            <field name="invoice_id" on_change="onchange_invoice_id(invoice_id,warehouse_id,context)" domain="['|',('commercial_partner_id','=',partner_id),('partner_id','=',partner_id)]" />
+                            <field name="invoice_id" on_change="onchange_invoice_id(invoice_id, warehouse_id, date, company_id, context)" domain="['|', ('commercial_partner_id', '=', partner_id), ('partner_id', '=', partner_id), ('type', '=', 'out_invoice'), ('state', 'in', ('open', 'paid'))]" context="{'form_view_ref': 'account.invoice_form'}"/>
                         </group>
                         <group>
                             <!-- Place for mass return button from crm_rma_lot_mass_return -->
                         </group>
                         <field name="claim_line_ids" nolabel="1" colspan="4" editable="top"/>
                     </group>
-                    <group col="4" colspan="4" attrs="{'invisible':[('state', '&lt;&gt;','open')]}">
-                        <separator string="Action" colspan="4" />
+                    <group attrs="{'invisible':[('state', '&lt;&gt;','open')]}" string="Actions on Product Returns" name="actions">
                         <button name="%(action_claim_picking_in)d"
                                 string="New Products Return" states="open"
                                 type="action" target="new"
@@ -188,7 +174,7 @@
 
                         <button name="%(account.action_account_invoice_refund)d"
                                 type='action' string='New Refund'
-                                states='open' icon="gtk-execute"
+                                states='open'
                                 context="{
                                     'invoice_ids': [invoice_id],
                                     'claim_line_ids': claim_line_ids,
@@ -198,118 +184,18 @@
                     </group>
                 </page>
                 <page string="Generated Documents">
-                    <separator colspan="2" string="Refunds"/>
-                    <field name="invoice_ids" colspan="4" readonly="1"/>
-                    <separator colspan="2" string="Receptions / Deliveries"/>
-                    <field name="picking_ids" colspan="4" readonly="1"/>
+                    <group name="refunds" string="Refunds">
+                        <field name="invoice_ids" readonly="1" nolabel="1"/>
+                    </group>
+                    <group name="picking" string="Receptions / Deliveries">
+                        <field name="picking_ids" readonly="1" nolabel="1"/>
+                    </group>
                 </page>
-	       </page>
+           </notebook>
         </field>
     </record>
 
 
-<!-- Right side link to orders -->
-        <act_window 
-        id="act_crm_claim_rma_sale_orders" 
-        name="Quotations and Sales"
-        res_model="sale.order"
-        src_model="crm.claim"/>
-<!-- Right side link to invoices -->
-        <act_window 
-        domain="[('type', '=', 'out_invoice')]"
-        id="act_crm_claim_rma_invoice_out" 
-        name="Customer Invoices" 
-        res_model="account.invoice" 
-        src_model="crm.claim"/>
-<!-- Right side link to invoices -->
-        <act_window 
-        domain="[('type', '=', 'in_invoice')]"
-        id="act_crm_claim_rma_invoice_in" 
-        name="Supplier Invoices" 
-        res_model="account.invoice" 
-        src_model="crm.claim"/>
-<!-- Right side link to refunds -->
-        <act_window 
-        domain="[('type', '=', 'out_refund')]"
-        id="act_crm_claim_rma_refunds_out" 
-        name="Customer Refunds" 
-        res_model="account.invoice" 
-        src_model="crm.claim"/>    
-<!-- Right side link to refunds -->
-        <act_window 
-        domain="[('type', '=', 'in_refund')]"
-        id="act_crm_claim_rma_refunds_in" 
-        name="Supplier Refunds" 
-        res_model="account.invoice" 
-        src_model="crm.claim"/> 
-<!-- Right side link to picking in --> 
-        <act_window
-        domain="[('type', '=', 'in')]"
-        id="act_crm_claim_rma_picking_in" 
-        name="Incomming Shipment and Returns" 
-        res_model="stock.picking" 
-        src_model="crm.claim"/>  
-<!-- Right side link to picking out -->
-        <act_window 
-        domain="[('type', '=', 'out')]"
-        id="act_crm_claim_rma_picking_out" 
-        name="Deliveries" 
-        res_model="stock.picking" 
-        src_model="crm.claim"/>  
-
-    <record model="ir.ui.view" id="crm_claim_rma_form_view2">
-        <field name="name">CRM - Claim product return Form</field>
-        <field name="model">crm.claim</field>
-        <field name="inherit_id" ref="crm_claim.crm_case_claims_form_view"/>
-            <field name="arch" type="xml">
-                <field name="date_deadline" position="after">
-                    <field name="claim_type"/>
-                    <field name="warehouse_id" />
-                </field>
-                <field name="name" position="replace">
-                    <div class="oe_title">
-                        <label for="number" class="oe_edit_only"/>
-                        <h1><field name="number"/></h1>
-                    </div>
-                </field>
-                <field name="date" position="replace">
-                </field>
-                <field name="user_id" position="before">
-                    <field name="name" />
-                    <field name="date"/>
-                </field>
-                <xpath expr="//sheet[@string='Claims']/group[1]" position="inside">
-                    <div class="oe_right oe_button_box" name="buttons">
-                        <button name="%(act_crm_claim_rma_sale_orders)d" type="action"
-                                string="Quotations and Sales"
-                                attrs="{'invisible': ['|',('partner_id','=', False),('claim_type','in', ['supplier','other'])]}"
-                                context="{'search_default_partner_id': [partner_id],'search_default_user_id':False}"
-                               />
-                        <button name="%(act_crm_claim_rma_invoice_out)d" type="action"
-                                string="Customer Invoices"
-                                attrs="{'invisible': ['|',('partner_id','=', False),('claim_type','in', ['supplier','other'])]}"
-                                context="{'search_default_partner_id': [partner_id],'search_default_user_id':False}"
-                               />
-                        <button name="%(act_crm_claim_rma_refunds_out)d" type="action"
-                                string="Customer Refunds"
-                                attrs="{'invisible': ['|',('partner_id','=', False),('claim_type','in', ['supplier','other'])]}"
-                                context="{'search_default_partner_id': [partner_id],'search_default_user_id':False}"
-                               />
-                        <button name="%(act_crm_claim_rma_invoice_in)d" type="action"
-                                string="Supplier Invoices"
-                                attrs="{'invisible': ['|',('partner_id','=', False),('claim_type','in', ['customer','other'])]}"
-                                context="{'search_default_partner_id': [partner_id],'search_default_user_id':False}"
-                               />
-                        <button name="%(act_crm_claim_rma_refunds_in)d" type="action"
-                                string="Supplier Refunds"
-                                attrs="{'invisible': ['|',('partner_id','=', False),('claim_type','in', ['customer','other'])]}"
-                                context="{'search_default_partner_id': [partner_id],'search_default_user_id':False}"
-                               />
-                    </div>
-                </xpath>
-            </field>
-    </record>
-
  <!-- Crm claim Search view -->
     <record id="view_crm_case_claims_filter" model="ir.ui.view">
         <field name="name">CRM - Claims Search</field>
@@ -319,13 +205,36 @@
             <field name="name" string="Claims" position="before">
                 <field name="number"/>
             </field>
-            <filter string="Stage" icon="terp-stage" domain="[]" context="{'group_by':'stage_id'}" position="before">
-                <filter string="Sales Team" icon="terp-stock_symbol-selection" domain="[]" context="{'group_by':'section_id'}"/>
+            <filter string="Stage" domain="[]" context="{'group_by':'stage_id'}" position="before">
+                <filter string="Sales Team" domain="[]" context="{'group_by':'section_id'}"/>
             </filter>
         </field>
     </record>
 
-       
+    <record id="substate_substate_form" model="ir.ui.view">
+        <field name="name">substate.substate.form</field>
+        <field name="model">substate.substate</field>
+        <field name="arch" type="xml">
+            <form string="Return Line Substates" version="7.0">
+                <group name="main">
+                    <field name="name"/>
+                    <field name="substate_descr"/>
+                </group>
+            </form>
+        </field>
+    </record>
+
+    <record id="substate_substate_tree" model="ir.ui.view">
+        <field name="name">substate.substate.tree</field>
+        <field name="model">substate.substate</field>
+        <field name="arch" type="xml">
+            <tree string="Return Line Substates">
+                <field name="name"/>
+            </tree>
+        </field>
+    </record>
+
+
 <!-- Menu -->
         <record model="ir.actions.act_window" id="crm_claim.crm_case_categ_claim0">
             <field name="context">{"search_default_user_id":uid, "stage_type":'claim'}</field>
@@ -333,23 +242,28 @@
 
     <!-- return lines action -->
         <record model="ir.actions.act_window" id="act_crm_case_claim_lines">
-            <field name="name">Claim lines</field>
+            <field name="name">Return Lines</field>
             <field name="res_model">claim.line</field>
             <field name="view_type">form</field>
             <field name="view_mode">tree,form</field>
-            <field name="view_id" ref="crm_claim_line_tree_view"/>
-            <field name="search_view_id" ref="view_crm_claim_lines_filter"/>
+            <field name="context">{'claim_line_main_view': True}</field>
         </record>
     <!-- substates action -->
         <record id="act_crm_claim_substates" model="ir.actions.act_window">
-            <field name="name">Claim line substates</field>
+            <field name="name">Return Line Substates</field>
             <field name="res_model">substate.substate</field>
             <field name="view_type">form</field>
+            <field name="view_mode">tree,form</field>
         </record>
     <!-- Menu -->
-        <menuitem name="Return lines" id="menu_crm_case_claims_claim_lines"
+        <menuitem id="menu_crm_case_claims_claim_lines"
             parent="base.menu_aftersale" action="act_crm_case_claim_lines" sequence="2"/>
-        <menuitem name="Returned line substates" id="menu_crm_case_claims_claim_line_substates"
+        <menuitem id="menu_crm_case_claims_claim_line_substates"
             parent="crm_claim.menu_config_claim" action="act_crm_claim_substates" sequence="2"/>
+
+        <!-- Add group RMA User to menu entry "After-Sale Services" -->
+        <record id="base.menu_aftersale" model="ir.ui.menu">
+            <field name="groups_id" eval="[(4, ref('group_rma_user'))]"/>
+        </record>
      </data>
 </openerp>

=== modified file 'crm_claim_rma/i18n/fr.po'
--- crm_claim_rma/i18n/fr.po	2014-01-23 05:58:36 +0000
+++ crm_claim_rma/i18n/fr.po	2014-04-15 21:39:34 +0000
@@ -365,7 +365,7 @@
 #: view:crm.claim:0
 #: model:ir.actions.act_window,name:crm_claim_rma.act_crm_claim_rma_refunds_out
 msgid "Customer Refunds"
-msgstr "Remboussements client"
+msgstr "Remboursements client"
 
 #. module: crm_claim_rma
 #: field:claim.line,location_dest_id:0

=== modified file 'crm_claim_rma/security/ir.model.access.csv'
--- crm_claim_rma/security/ir.model.access.csv	2013-02-11 14:26:42 +0000
+++ crm_claim_rma/security/ir.model.access.csv	2014-04-15 21:39:34 +0000
@@ -1,7 +1,14 @@
-"id","name","model_id:id","group_id:id","perm_read","perm_write","perm_create","perm_unlink"
-"access_substate_user","substate.substate.user","model_substate_substate","base.group_sale_salesman_all_leads","True","True","True",
-"access_claim_line_user","claim.line.user","model_claim_line","base.group_sale_salesman_all_leads","True","True","True",
-"access_substate_manager","substate.substate.manager","model_substate_substate","base.group_sale_manager","True","True","True","True"
-"access_claim_line_manager","claim.line.manager","model_claim_line","base.group_sale_manager","True","True","True","True"
-"access_substate_user","substate.substate.user","model_substate_substate","base.group_sale_salesman","True","True","True",
-"access_claim_line_user","claim.line.user","model_claim_line","base.group_sale_salesman","True","True","True",
+id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
+access_substate_user,Read access on substate.substate to Sale User,model_substate_substate,base.group_sale_salesman,1,0,0,0
+access_substate_manager,substate.substate.manager,model_substate_substate,base.group_sale_manager,1,1,1,1
+access_substate_rma_user,Read access on substate.substate to RMA User,model_substate_substate,group_rma_user,1,0,0,0
+access_substate_rma_manager,Full access on substate.substate to RMA Manager,model_substate_substate,group_rma_manager,1,1,1,1
+access_claim_line_user,claim.line.user,model_claim_line,base.group_sale_salesman,1,1,1,0
+access_claim_line_manager,claim.line.manager,model_claim_line,base.group_sale_manager,1,1,1,1
+access_claim_line_rma_user,Access on claim.line to RMA User,model_claim_line,group_rma_user,1,1,1,0
+access_claim_line_rma_manager,Full Access on claim.line to RMA Manager,model_claim_line,group_rma_manager,1,1,1,1
+access_crm_claim_rma_user,Access on crm.claim to RMA User,crm_claim.model_crm_claim,group_rma_user,1,1,1,0
+access_crm_claim_rma_manager,Access on crm.claim to RMA Manager,crm_claim.model_crm_claim,group_rma_manager,1,1,1,1
+access_crm_claim_stage_rma_user,Access on crm.claim.stage to RMA User,crm_claim.model_crm_claim_stage,group_rma_user,1,0,0,0
+access_crm_claim_stage_rma_manager,Full access on crm.claim.stage to RMA Manager,crm_claim.model_crm_claim_stage,group_rma_manager,1,1,1,1
+access_crm_claim_report_rma_manager,Full access on crm.claim.report to RMA Manager,crm_claim.model_crm_claim_report,group_rma_manager,1,1,1,1

=== added file 'crm_claim_rma/security/rma_group.xml'
--- crm_claim_rma/security/rma_group.xml	1970-01-01 00:00:00 +0000
+++ crm_claim_rma/security/rma_group.xml	2014-04-15 21:39:34 +0000
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+    Copyright (C) 2014 Akretion (http://www.akretion.com/)
+    @author: Alexis de Lattre <alexis.delattre@xxxxxxxxxxxx>
+    The licence is in the file __openerp__.py
+-->
+
+<openerp>
+<data noupdate="1">
+
+
+<record id="module_category_rma" model="ir.module.category">
+    <field name="name">RMA</field>
+    <field name="sequence">30</field>
+</record>
+
+<record id="group_rma_user" model="res.groups">
+    <field name="name">User</field>
+    <field name="category_id" ref="module_category_rma"/>
+</record>
+
+<record id="group_rma_manager" model="res.groups">
+    <field name="name">Manager</field>
+    <field name="category_id" ref="module_category_rma"/>
+    <field name="implied_ids" eval="[(4, ref('group_rma_user'))]"/>
+</record>
+
+
+</data>
+</openerp>

=== modified file 'crm_claim_rma/stock_view.xml'
--- crm_claim_rma/stock_view.xml	2013-11-14 10:07:54 +0000
+++ crm_claim_rma/stock_view.xml	2014-04-15 21:39:34 +0000
@@ -24,15 +24,15 @@
                 </xpath>
             </field>
         </record>
-        
+
         <record id="view_picking_in_search" model="ir.ui.view">
             <field name="name">crm_claim_rma.picking_in_search</field>
             <field name="model">stock.picking.in</field>
             <field name="inherit_id" ref="stock.view_picking_in_search" />
             <field name="arch" type="xml">
-                <filter string="To Invoice" name="to_invoice" icon="terp-dolar" domain="[('invoice_state', '=', '2binvoiced')]" position="after">
+                <filter string="To Invoice" name="to_invoice" position="after">
                     <separator/>
-                    <filter string="RMA" icon="terp-accessories-archiver-minus" domain="[('claim_id', '!=', 'False')]" />
+                    <filter string="RMA" domain="[('claim_id', '!=', 'False')]" />
                 </filter>
             </field>
         </record>
@@ -42,9 +42,9 @@
             <field name="model">stock.picking.out</field>
             <field name="inherit_id" ref="stock.view_picking_out_search" />
             <field name="arch" type="xml">
-                <filter icon="terp-dolar" name="to_invoice" string="To Invoice" domain="[('invoice_state','=','2binvoiced')]" help="Delivery orders to invoice" position="after">
+                <filter name="to_invoice" string="To Invoice" position="after">
                     <separator/>
-                    <filter string="RMA" icon="terp-accessories-archiver-minus" domain="[('claim_id', '!=', 'False')]" />
+                    <filter string="RMA" domain="[('claim_id', '!=', 'False')]" />
                 </filter>
             </field>
         </record>

=== modified file 'crm_claim_rma/wizard/claim_make_picking_view.xml'
--- crm_claim_rma/wizard/claim_make_picking_view.xml	2013-12-20 14:31:15 +0000
+++ crm_claim_rma/wizard/claim_make_picking_view.xml	2014-04-15 21:39:34 +0000
@@ -12,13 +12,15 @@
             <field name="model">claim_make_picking.wizard</field>
             <field name="arch" type="xml">
                 <form string="Select exchange lines to add in picking" version="7.0">
-                    <separator string="Locations" colspan="4"/>
-                    <field name="claim_line_source_location" nolabel="1" />
-                    <field name="claim_line_dest_location" nolabel="1" />
-                    <separator string="Select lines for picking" colspan="4"/>
-                    <field name="claim_line_ids" nolabel="1" colspan="4"/>
+                    <group name="locations" string="Locations">
+                        <field name="claim_line_source_location" />
+                        <field name="claim_line_dest_location" />
+                    </group>
+                    <group name="lines" string="Select Lines for Picking">
+                        <field name="claim_line_ids" nolabel="1"/>
+                    </group>
                     <footer>
-                        <button name="action_create_picking" string="Create picking" type="object" class="oe_highlight"/>
+                        <button name="action_create_picking" string="Create Picking" type="object" class="oe_highlight"/>
                         or
                         <button string="Cancel" class="oe_link" special="cancel" />
                     </footer>
@@ -28,7 +30,6 @@
 
         <record id="action_claim_picking_in" model="ir.actions.act_window">
             <field name="name">Return Products</field>
-            <field name="type">ir.actions.act_window</field>
             <field name="res_model">claim_make_picking.wizard</field>
             <field name="src_model">crm.claim</field>
             <field name="view_type">form</field>
@@ -39,7 +40,6 @@
 
         <record id="action_claim_picking_out" model="ir.actions.act_window">
             <field name="name">Create Outgoing Shipments</field>
-            <field name="type">ir.actions.act_window</field>
             <field name="res_model">claim_make_picking.wizard</field>
             <field name="src_model">crm.claim</field>
             <field name="view_type">form</field>

=== modified file 'crm_rma_advance_location/__openerp__.py'
--- crm_rma_advance_location/__openerp__.py	2013-11-15 13:24:39 +0000
+++ crm_rma_advance_location/__openerp__.py	2014-04-15 21:39:34 +0000
@@ -2,7 +2,7 @@
 ##############################################################################
 #
 #    Copyright 2013 Camptocamp
-#    Copyright 2009-2013 Akretion, 
+#    Copyright 2009-2013 Akretion
 #    Author: Emmanuel Samyn, Raphaël Valyi, Sébastien Beau, Joel Grand-Guillaume
 #
 #    This program is free software: you can redistribute it and/or modify
@@ -40,10 +40,10 @@
  * Refurbish
  * Mistake Loss
 
-And also various wizards on icoming deliveries that allow you to move your goods easily in those
+And also various wizards on incoming deliveries that allow you to move your goods easily to those
 new locations from a done reception.
 
-Using this module make the logistic flow of return a bit more complexe:
+Using this module make the logistic flow of return a bit more complex:
 
  * Returning product goes into RMA location with a incoming shipment
  * From the incoming shipment, forward them to another places (stock, loss,...)

=== modified file 'crm_rma_advance_location/claim_rma_view.xml'
--- crm_rma_advance_location/claim_rma_view.xml	2013-11-15 13:24:39 +0000
+++ crm_rma_advance_location/claim_rma_view.xml	2014-04-15 21:39:34 +0000
@@ -1,20 +1,22 @@
 <?xml version="1.0"?>
 <openerp>
-    <data>
-    <record model="ir.ui.view" id="crm_claim_rma_form_view">
-        <field name="name">CRM - Claim product return Form</field>
-        <field name="model">crm.claim</field>
-        <field name="inherit_id" ref="crm_claim_rma.crm_claim_rma_form_view"/>
-        <field name="arch" type="xml">
-            <xpath expr="//button[@string='New Delivery']" position="after">
-                <button name="%(action_claim_picking_loss)d"
-                                string="New Product Loss" states="open"
-                                type="action" target="new"
-                                context="{'warehouse_id': warehouse_id,
-                                    'partner_id': partner_id}"/>
-            </xpath>
-        </field>
-    </record>
-
-     </data>
+<data>
+
+<record id="crm_claim_rma_form_view" model="ir.ui.view">
+    <field name="name">CRM - Claim product return Form</field>
+    <field name="model">crm.claim</field>
+    <field name="inherit_id" ref="crm_claim_rma.crm_case_claims_form_view"/>
+    <field name="arch" type="xml">
+        <xpath expr="//button[@string='New Delivery']" position="after">
+            <button name="%(action_claim_picking_loss)d"
+                    string="New Product Loss" states="open"
+                    type="action" target="new"
+                    context="{'warehouse_id': warehouse_id,
+                            'partner_id': partner_id}"/>
+        </xpath>
+    </field>
+</record>
+
+
+</data>
 </openerp>

=== modified file 'crm_rma_advance_location/stock.py'
--- crm_rma_advance_location/stock.py	2013-12-03 10:27:02 +0000
+++ crm_rma_advance_location/stock.py	2014-04-15 21:39:34 +0000
@@ -2,7 +2,7 @@
 ##############################################################################
 #
 #    Copyright 2013 Camptocamp
-#    Copyright 2009-2013 Akretion, 
+#    Copyright 2009-2013 Akretion
 #    Author: Emmanuel Samyn, Raphaël Valyi, Sébastien Beau, Joel Grand-Guillaume
 #
 #    This program is free software: you can redistribute it and/or modify

=== modified file 'crm_rma_advance_location/stock_view.xml'
--- crm_rma_advance_location/stock_view.xml	2013-11-14 10:07:54 +0000
+++ crm_rma_advance_location/stock_view.xml	2014-04-15 21:39:34 +0000
@@ -11,7 +11,7 @@
                 <!-- Those wizard aren't working yet -->
                 <xpath expr="/form/header/button[@string='Return Products']" position="after">
                         <button name="%(action_stock_picking_from_claim_picking)d" 
-                                string="Product to stock" type="action"
+                                string="Product to Stock" type="action"
                                 attrs="{'invisible':['|',
                                                     ('state','&lt;&gt;','done'),
                                                     ('claim_id', '=', False)]}"/>
@@ -21,7 +21,7 @@
                                                     ('state','&lt;&gt;','done'),
                                                     ('claim_id', '=', False)]}"/>
                         <button name="%(action_used_picking_from_claim_picking)d" 
-                                string="Product to refurbish stock" type="action"
+                                string="Product to Refurbish" type="action"
                                 attrs="{'invisible':['|',
                                                     ('state','&lt;&gt;','done'),
                                                     ('claim_id', '=', False)]}"/>
@@ -42,7 +42,6 @@
                 </xpath>
             </field>
         </record>
-        
 
     </data>
 </openerp>

=== modified file 'crm_rma_advance_location/wizard/__init__.py'
--- crm_rma_advance_location/wizard/__init__.py	2013-11-14 10:07:54 +0000
+++ crm_rma_advance_location/wizard/__init__.py	2014-04-15 21:39:34 +0000
@@ -2,7 +2,7 @@
 ##############################################################################
 #
 #    Copyright 2013 Camptocamp
-#    Copyright 2009-2013 Akretion, 
+#    Copyright 2009-2013 Akretion
 #    Author: Emmanuel Samyn, Raphaël Valyi, Sébastien Beau, Joel Grand-Guillaume
 #
 #    This program is free software: you can redistribute it and/or modify
@@ -20,4 +20,4 @@
 #
 ##############################################################################
 from . import claim_make_picking_from_picking
-from . import claim_make_picking
\ No newline at end of file
+from . import claim_make_picking

=== modified file 'crm_rma_advance_location/wizard/claim_make_picking.py'
--- crm_rma_advance_location/wizard/claim_make_picking.py	2013-12-03 10:33:50 +0000
+++ crm_rma_advance_location/wizard/claim_make_picking.py	2014-04-15 21:39:34 +0000
@@ -1,26 +1,28 @@
 # -*- coding: utf-8 -*-
 #########################################################################
-#                                                                       #
-#                                                                       #
-#########################################################################
-#                                                                       #
-# crm_claim_rma for OpenERP                                             #
-# Copyright (C) 2009-2012  Akretion, Emmanuel Samyn,                    #
-#       Benoît GUILLOT <benoit.guillot@xxxxxxxxxxxx>                    #
-#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   #
-#the Free Software Foundation, either version 3 of the License, or      #
-#(at your option) any later version.                                    #
-#                                                                       #
-#This program is distributed in the hope that it will be useful,        #
-#but WITHOUT ANY WARRANTY; without even the implied warranty of         #
-#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          #
-#GNU General Public License for more details.                           #
-#                                                                       #
-#You should have received a copy of the GNU General Public License      #
-#along with this program.  If not, see <http://www.gnu.org/licenses/>.  #
-#########################################################################
+#
+#    crm_claim_rma_advance_location for OpenERP
+#    Copyright (C) 2009-2014 Emmanuel Samyn
+#    Copyright (C) 2009-2014 Akretion (http://www.akretion.com)
+#    Authors: Emmanuel Samyn, Benoît GUILLOT <benoit.guillot@xxxxxxxxxxxx>
+#
+#    This program is free software: you can redistribute it and/or modify
+#    it under the terms of the GNU Affero General Public License as
+#    published by the Free Software Foundation, either version 3 of the
+#    License, or (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU Affero General Public License for more details.
+#
+#    You should have received a copy of the GNU Affero General Public License
+#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
+#
+#########################################################################
+
 from openerp.osv import orm
+from openerp.tools.translate import _
 
 
 class claim_make_picking(orm.TransientModel):
@@ -29,23 +31,27 @@
 
     def _get_dest_loc(self, cr, uid, context=None):
         """ Get default destination location """
-        loc_id = super(claim_make_picking, self)._get_dest_loc(cr, uid, context=context)
         if context is None:
             context = {}
-        warehouse_obj = self.pool.get('stock.warehouse')
+        loc_id = super(claim_make_picking, self)._get_dest_loc(
+            cr, uid, context=context)
         warehouse_id = context.get('warehouse_id')
+        warehouse = self.pool['stock.warehouse'].browse(
+            cr, uid, warehouse_id, context=context)
         if context.get('picking_type') == 'in':
-            loc_id = warehouse_obj.read(
-                cr, uid,
-                warehouse_id,
-                ['lot_rma_id'],
-                context=context)['lot_rma_id'][0]
+            loc_id = warehouse.lot_rma_id.id or False
+            if not loc_id:
+                raise orm.except_orm(
+                    _('Error:'),
+                    _("Missing RMA stock location on warehouse '%s'")
+                    % warehouse.name)
         elif context.get('picking_type') == 'loss':
-            loc_id = warehouse_obj.read(
-                cr, uid,
-                warehouse_id,
-                ['lot_carrier_loss_id'],
-                context=context)['lot_carrier_loss_id'][0]
+            loc_id = warehouse.lot_carrier_loss_id.id or False
+            if not loc_id:
+                raise orm.except_orm(
+                    _('Error:'),
+                    _("Missing Carrier Loss stock location on warehouse '%s'")
+                    % warehouse.name)
         return loc_id
 
     _defaults = {

=== modified file 'crm_rma_advance_location/wizard/claim_make_picking_from_picking.py'
--- crm_rma_advance_location/wizard/claim_make_picking_from_picking.py	2013-11-21 15:41:37 +0000
+++ crm_rma_advance_location/wizard/claim_make_picking_from_picking.py	2014-04-15 21:39:34 +0000
@@ -1,27 +1,28 @@
 # -*- coding: utf-8 -*-
 #########################################################################
-#                                                                       #
-#                                                                       #
-#########################################################################
-#                                                                       #
-# crm_claim_rma for OpenERP                                             #
-# Copyright (C) 2009-2012  Akretion, Emmanuel Samyn,                    #
-#       Benoît GUILLOT <benoit.guillot@xxxxxxxxxxxx>                    #
-#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   #
-#the Free Software Foundation, either version 3 of the License, or      #
-#(at your option) any later version.                                    #
-#                                                                       #
-#This program is distributed in the hope that it will be useful,        #
-#but WITHOUT ANY WARRANTY; without even the implied warranty of         #
-#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          #
-#GNU General Public License for more details.                           #
-#                                                                       #
-#You should have received a copy of the GNU General Public License      #
-#along with this program.  If not, see <http://www.gnu.org/licenses/>.  #
-#########################################################################
+#
+#    crm_claim_rma_advance_location for OpenERP
+#    Copyright (C) 2009-2014 Emmanuel Samyn
+#    Copyright (C) 2009-2014 Akretion (http://www.akretion.com)
+#    Authors: Emmanuel Samyn, Benoît GUILLOT <benoit.guillot@xxxxxxxxxxxx>
+#
+#    This program is free software: you can redistribute it and/or modify
+#    it under the terms of the GNU Affero General Public License as
+#    published by the Free Software Foundation, either version 3 of the
+#    License, or (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU Affero General Public License for more details.
+#
+#    You should have received a copy of the GNU Affero General Public License
+#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
+#
+#########################################################################
+
 from openerp.osv import fields, orm
-from openerp.tools import DEFAULT_SERVER_DATE_FORMAT, DEFAULT_SERVER_DATETIME_FORMAT
+from openerp.tools import DEFAULT_SERVER_DATETIME_FORMAT
 from openerp import netsvc
 import time
 
@@ -31,15 +32,16 @@
     _name = 'claim_make_picking_from_picking.wizard'
     _description = 'Wizard to create pickings from picking lines'
     _columns = {
-        'picking_line_source_location': fields.many2one('stock.location',
-            'Source Location',
+        'picking_line_source_location': fields.many2one(
+            'stock.location', 'Source Location',
             help="Location where the returned products are from.",
             required=True),
-        'picking_line_dest_location': fields.many2one('stock.location',
-            'Dest. Location',
+        'picking_line_dest_location': fields.many2one(
+            'stock.location', 'Dest. Location',
             help="Location where the system will stock the returned products.",
             required=True),
-        'picking_line_ids': fields.many2many('stock.move',
+        'picking_line_ids': fields.many2many(
+            'stock.move',
             'claim_picking_line_picking',
             'claim_picking_id',
             'picking_line_id',
@@ -47,31 +49,36 @@
     }
 
     def _get_default_warehouse(self, cr, uid, context=None):
-        warehouse_id=self.pool.get('crm.claim')._get_default_warehouse(cr, uid, context=context)
+        warehouse_id = self.pool['crm.claim']._get_default_warehouse(
+            cr, uid, context=context)
         return warehouse_id
 
     def _get_picking_lines(self, cr, uid, context):
-        return self.pool.get('stock.picking').read(cr, uid,
-            context['active_id'], ['move_lines'], context=context)['move_lines']
+        return self.pool.get('stock.picking').read(
+            cr, uid, context['active_id'], ['move_lines'],
+            context=context)['move_lines']
 
     # Get default source location
     def _get_source_loc(self, cr, uid, context):
-        if context is None: context = {}
+        if context is None:
+            context = {}
         warehouse_obj = self.pool.get('stock.warehouse')
         warehouse_id = self._get_default_warehouse(cr, uid, context=context)
-        return warehouse_obj.read(cr, uid,
-            warehouse_id, ['lot_rma_id'], context=context)['lot_rma_id'][0]
+        return warehouse_obj.read(
+            cr, uid, warehouse_id, ['lot_rma_id'],
+            context=context)['lot_rma_id'][0]
 
     # Get default destination location
     def _get_dest_loc(self, cr, uid, context):
-        if context is None: context = {}
+        if context is None:
+            context = {}
         warehouse_id = self._get_default_warehouse(cr, uid, context=context)
         warehouse_obj = self.pool.get('stock.warehouse')
         if context.get('picking_type'):
-            context_loc = context.get('picking_type')[8:]
-            loc_field = 'lot_%s_id' %context.get('picking_type')[8:]
-            loc_id = warehouse_obj.read(cr, uid,
-                warehouse_id, [loc_field], context=context)[loc_field][0]
+            loc_field = 'lot_%s_id' % context.get('picking_type')[8:]
+            loc_id = warehouse_obj.read(
+                cr, uid, warehouse_id, [loc_field],
+                context=context)[loc_field][0]
         return loc_id
 
     _defaults = {
@@ -80,9 +87,6 @@
         'picking_line_ids': _get_picking_lines,
     }
 
-    def action_cancel(self,cr,uid,ids,conect=None):
-        return {'type': 'ir.actions.act_window_close',}
-
     # If "Create" button pressed
     def action_create_picking_from_picking(self, cr, uid, ids, context=None):
         picking_obj = self.pool.get('stock.picking')
@@ -162,5 +166,3 @@
             'res_id': picking_id,
             'type': 'ir.actions.act_window',
         }
-
-# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

=== modified file 'crm_rma_advance_location/wizard/claim_make_picking_from_picking_view.xml'
--- crm_rma_advance_location/wizard/claim_make_picking_from_picking_view.xml	2013-11-14 10:07:54 +0000
+++ crm_rma_advance_location/wizard/claim_make_picking_from_picking_view.xml	2014-04-15 21:39:34 +0000
@@ -1,6 +1,5 @@
 <?xml version="1.0" encoding="utf-8"?>
 <!--
-  crm_claim_rma for OpenERP
   Copyright (C) 2011 Akretion Benoît GUILLOT <benoit.guillot@xxxxxxxxxxxx>
   The licence is in the file __openerp__.py
 -->
@@ -11,26 +10,27 @@
             <field name="name">claim_picking</field>
             <field name="model">claim_make_picking_from_picking.wizard</field>
             <field name="arch" type="xml">
-                <form string="Select lines to add in picking">
-                    <separator string="Locations" colspan="4"/>
-                    <field name="picking_line_source_location" nolabel="1" />
-                    <field name="picking_line_dest_location" nolabel="1" />
-                    <separator string="Select lines for picking" colspan="4"/>
-                    <field name="picking_line_ids" nolabel="1" colspan="4"/>
-                    <group col="4" colspan="2">
-                        <button special="cancel" string="Cancel" name="action_cancel" type="object" icon='gtk-cancel'/>
-                        <button name="action_create_picking_from_picking" string="Create picking" 
-                                icon='gtk-ok' type="object"/>
-                    </group>
+                <form string="Select lines to add in picking" version="7.0">
+                    <group string="Locations">
+                        <field name="picking_line_source_location" />
+                        <field name="picking_line_dest_location" />
+                    </group>
+                    <group string="Select lines for picking">
+                        <field name="picking_line_ids" nolabel="1"/>
+                    </group>
+                    <footer>
+                        <button name="action_create_picking_from_picking"
+                            string="Create Picking"
+                            class="oe_highlight" type="object"/>
+                        <button special="cancel" string="Cancel" type="object" class="oe_link"/>
+                    </footer>
                 </form>
             </field>
-        </record> 
+        </record>
 
         <record id="action_stock_picking_from_claim_picking" model="ir.actions.act_window">
             <field name="name">Create Incomming Shipment to Stock</field>
-            <field name="type">ir.actions.act_window</field>
             <field name="res_model">claim_make_picking_from_picking.wizard</field>
-            <field name="src_model">stock.picking</field>
             <field name="view_type">form</field>
             <field name="view_mode">form</field>
             <field name="target">new</field> 
@@ -39,9 +39,7 @@
 
         <record id="action_loss_picking_from_claim_picking" model="ir.actions.act_window">
             <field name="name">Create Incomming Shipment to Breakkage Loss Location</field>
-            <field name="type">ir.actions.act_window</field>
             <field name="res_model">claim_make_picking_from_picking.wizard</field>
-            <field name="src_model">stock.picking</field>
             <field name="view_type">form</field>
             <field name="view_mode">form</field>
             <field name="target">new</field> 
@@ -50,9 +48,7 @@
 
         <record id="action_used_picking_from_claim_picking" model="ir.actions.act_window">
             <field name="name">Create Incomming Shipment to Refurbish Location</field>
-            <field name="type">ir.actions.act_window</field>
             <field name="res_model">claim_make_picking_from_picking.wizard</field>
-            <field name="src_model">stock.picking</field>
             <field name="view_type">form</field>
             <field name="view_mode">form</field>
             <field name="target">new</field> 

=== modified file 'crm_rma_advance_location/wizard/claim_make_picking_view.xml'
--- crm_rma_advance_location/wizard/claim_make_picking_view.xml	2013-11-14 10:07:54 +0000
+++ crm_rma_advance_location/wizard/claim_make_picking_view.xml	2014-04-15 21:39:34 +0000
@@ -1,6 +1,5 @@
 <?xml version="1.0" encoding="utf-8"?>
 <!--
-  crm_claim_rma for OpenERP
   Copyright (C) 2011 Akretion Benoît GUILLOT <benoit.guillot@xxxxxxxxxxxx>
   The licence is in the file __openerp__.py
 -->
@@ -9,9 +8,7 @@
 
         <record id="action_claim_picking_loss" model="ir.actions.act_window">
             <field name="name">Create Products Loss</field>
-            <field name="type">ir.actions.act_window</field>
             <field name="res_model">claim_make_picking.wizard</field>
-            <field name="src_model">crm.claim</field>
             <field name="view_type">form</field>
             <field name="view_mode">form</field>
             <field name="target">new</field> 

=== modified file 'product_warranty/__openerp__.py'
--- product_warranty/__openerp__.py	2013-11-21 15:08:21 +0000
+++ product_warranty/__openerp__.py	2014-04-15 21:39:34 +0000
@@ -47,7 +47,7 @@
         'res_company_view.xml',
         'product_warranty_view.xml',
     ],
-    'demo_xml': [],
+    'demo': [],
     'test': [],
     'installable': True,
     'active': False,

=== modified file 'product_warranty/product_warranty.py'
--- product_warranty/product_warranty.py	2013-12-03 10:26:17 +0000
+++ product_warranty/product_warranty.py	2014-04-15 21:39:34 +0000
@@ -1,26 +1,31 @@
 # -*- coding: utf-8 -*-
 #########################################################################
-#                                                                       #
-#                                                                       #
-#########################################################################
-#                                                                       #
-# Copyright (C) 2009-2011  Akretion, Emmanuel Samyn, Benoît Guillot     #
-#                                                                       #
-#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   #
-#the Free Software Foundation, either version 3 of the License, or      #
-#(at your option) any later version.                                    #
-#                                                                       #
-#This program is distributed in the hope that it will be useful,        #
-#but WITHOUT ANY WARRANTY; without even the implied warranty of         #
-#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          #
-#GNU General Public License for more details.                           #
-#                                                                       #
-#You should have received a copy of the GNU General Public License      #
-#along with this program.  If not, see <http://www.gnu.org/licenses/>.  #
+#
+#    Copyright (C) 2009-2014 Akretion (http://www.akretion.com/)
+#    Copyright (C) 2009-2014 Emmanuel Samyn
+#    Authors: Emmanuel Samyn, Raphaël Valyi, Sébastien Beau,
+#             Benoît Guillot, Joel Grand-Guillaume
+#
+#    This program is free software: you can redistribute it and/or modify
+#    it under the terms of the GNU Affero General Public License as
+#    published by the Free Software Foundation, either version 3 of the
+#    License, or (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU Affero General Public License for more details.
+#
+#    You should have received a copy of the GNU Affero General Public License
+#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
+#
 #########################################################################
 
 from openerp.osv import orm, fields
+import math
+from datetime import datetime
+from dateutil.relativedelta import relativedelta
+import calendar
 
 
 class return_instruction(orm.Model):
@@ -85,7 +90,7 @@
 
     _columns = {
         "warranty_duration": fields.float(
-            'Period',
+            'Product Warranty (in months)',
             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"),
@@ -121,3 +126,27 @@
         'warranty_return_partner': 'company',
         'return_instructions': _get_default_instructions,
     }
+
+
+class product_product(orm.Model):
+    _inherit = 'product.product'
+
+    def warranty_limit(self, cr, uid, start, warranty_duration, context=None):
+        """ Take a duration in float, return the duration in relativedelta
+
+        ``relative_delta(months=...)`` only accepts integers.
+        We have to extract the decimal part, and then, extend the delta with
+        days.
+
+        """
+        decimal_part, months = math.modf(warranty_duration)
+        months = int(months)
+        # If we have a decimal part, we add the number them as days to
+        # the limit.  We need to get the month to know the number of
+        # days.
+        delta = relativedelta(months=months)
+        monthday = start + delta
+        __, days_month = calendar.monthrange(monthday.year, monthday.month)
+        # ignore the rest of the days (hours) since we expect a date
+        days = int(days_month * decimal_part)
+        return start + relativedelta(months=months, days=days)

=== modified file 'product_warranty/res_company_view.xml'
--- product_warranty/res_company_view.xml	2013-11-21 15:08:21 +0000
+++ product_warranty/res_company_view.xml	2014-04-15 21:39:34 +0000
@@ -7,14 +7,12 @@
             <field name="name">crm_claim_rma.company_form</field>
             <field name="model">res.company</field>
             <field name="inherit_id" ref="base.view_company_form" />
-            <field eval="16" name="priority"/>
             <field name="arch" type="xml">
-                <data>
-                    <field name="company_registry" position="after">
-                        <separator string="Crm product return address" colspan="4"/>
+                <page string="Configuration" position="inside">
+                    <group name="product-warranty" string="Product Warranty">
                         <field name="crm_return_address_id"/>
-                    </field> 
-                </data>
+                    </group>
+                </page>
             </field>
         </record>
 


Follow ups