← Back to team overview

openerp-community-reviewer team mailing list archive

[Merge] lp:~akretion-team/openerp-rma/add-crm-claim-rma-repair into lp:openerp-rma

 

Alexis de Lattre has proposed merging lp:~akretion-team/openerp-rma/add-crm-claim-rma-repair into lp:openerp-rma with lp:~akretion-team/openerp-rma/rma-cleanup-cleanup-cleanup as a prerequisite.

Requested reviews:
  OpenERP RMA (openerprma)

For more details, see:
https://code.launchpad.net/~akretion-team/openerp-rma/add-crm-claim-rma-repair/+merge/215976

This MP adds the module crm_claim_rma_repair. It is a small module that adds the ability to create a repair from a CRM claim. It depends on 'mrp_repair' and 'crm_claim_rma'.
-- 
https://code.launchpad.net/~akretion-team/openerp-rma/add-crm-claim-rma-repair/+merge/215976
Your team OpenERP RMA is requested to review the proposed merge of lp:~akretion-team/openerp-rma/add-crm-claim-rma-repair into lp:openerp-rma.
=== added directory 'crm_claim_rma_repair'
=== added file 'crm_claim_rma_repair/__init__.py'
--- crm_claim_rma_repair/__init__.py	1970-01-01 00:00:00 +0000
+++ crm_claim_rma_repair/__init__.py	2014-04-15 22:17:58 +0000
@@ -0,0 +1,24 @@
+# -*- encoding: utf-8 -*-
+##############################################################################
+#
+#    CRM Claim RMA Repair module for OpenERP
+#    Copyright (C) 2014 Akretion (http://www.akretion.com)
+#    @author Alexis de Lattre <alexis.delattre@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 . import wizard
+from . import crm_claim

=== added file 'crm_claim_rma_repair/__openerp__.py'
--- crm_claim_rma_repair/__openerp__.py	1970-01-01 00:00:00 +0000
+++ crm_claim_rma_repair/__openerp__.py	2014-04-15 22:17:58 +0000
@@ -0,0 +1,46 @@
+# -*- encoding: utf-8 -*-
+##############################################################################
+#
+#    CRM Claim RMA Repair extension module for OpenERP
+#    Copyright (C) 2014 Akretion (http://www.akretion.com)
+#    @author Alexis de Lattre <alexis.delattre@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/>.
+#
+##############################################################################
+
+
+{
+    'name': 'CRM Claim RMA Repair',
+    'version': '0.1',
+    'category': 'Customer Relationship Management',
+    'license': 'AGPL-3',
+    'summary': 'Connect crm_claim_rma with mrp_repair',
+    'description': """
+CRM Claim RMA Repair
+====================
+
+Add ability to create a repair from a CRM claim.
+
+Please contact Alexis de Lattre from Akretion <alexis.delattre@xxxxxxxxxxxx> for any help or question about this module.
+    """,
+    'author': 'Akretion',
+    'website': 'http://www.akretion.com',
+    'depends': ['mrp_repair', 'crm_claim_rma'],
+    'data': [
+        'wizard/claim_make_repair_view.xml',
+        'crm_claim_view.xml',
+        ],
+    'active': False,
+}

=== added file 'crm_claim_rma_repair/crm_claim.py'
--- crm_claim_rma_repair/crm_claim.py	1970-01-01 00:00:00 +0000
+++ crm_claim_rma_repair/crm_claim.py	2014-04-15 22:17:58 +0000
@@ -0,0 +1,43 @@
+# -*- encoding: utf-8 -*-
+##############################################################################
+#
+#    CRM Claim RMA Repair module for OpenERP
+#    Copyright (C) 2014 Akretion (http://www.akretion.com)
+#    @author Alexis de Lattre <alexis.delattre@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, fields
+
+
+class claim_line(orm.Model):
+    _inherit = 'claim.line'
+
+    _columns = {
+        'repair_id': fields.many2one('mrp.repair', 'Repair'),
+        }
+
+
+class mrp_repair(orm.Model):
+    _inherit = "mrp.repair"
+
+    _columns = {
+        # remove required=True on the native 'move_id' field
+        'move_id': fields.many2one(
+            'stock.move', 'Move', required=False,
+            domain="[('product_id', '=', product_id)]", readonly=True,
+            states={'draft': [('readonly', False)]}),
+        }

=== added file 'crm_claim_rma_repair/crm_claim_view.xml'
--- crm_claim_rma_repair/crm_claim_view.xml	1970-01-01 00:00:00 +0000
+++ crm_claim_rma_repair/crm_claim_view.xml	2014-04-15 22:17:58 +0000
@@ -0,0 +1,51 @@
+<?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>
+
+
+<record id="crm_claim_line_tree_view" model="ir.ui.view">
+    <field name="name">repair.crm.claim.line.tree</field>
+    <field name="model">claim.line</field>
+    <field name="inherit_id" ref="crm_claim_rma.crm_claim_line_tree_view" />
+    <field name="arch" type="xml">
+        <field name="move_out_id" position="after">
+            <field name="repair_id"/>
+        </field>
+    </field>
+</record>
+
+<record id="crm_claim_line_form_view" model="ir.ui.view">
+    <field name="name">repair.crm.claim.line.form</field>
+    <field name="model">claim.line</field>
+    <field name="inherit_id" ref="crm_claim_rma.crm_claim_line_form_view"/>
+    <field name="arch" type="xml">
+        <field name="move_out_id" position="after">
+            <field name="repair_id"/>
+        </field>
+    </field>
+</record>
+
+<record id="crm_claim_rma_form_view" model="ir.ui.view">
+    <field name="name">repair.crm.claim.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">
+        <group name="actions" position="attributes">
+            <attribute name="col">6</attribute>
+        </group>
+        <group name="actions" position="inside">
+            <button name="%(action_claim_make_repair)d" string="New Repair"
+                type="action" states="open"/>
+        </group>
+    </field>
+</record>
+
+</data>
+</openerp>

=== added directory 'crm_claim_rma_repair/i18n'
=== added file 'crm_claim_rma_repair/i18n/crm_claim_rma_repair.pot'
--- crm_claim_rma_repair/i18n/crm_claim_rma_repair.pot	1970-01-01 00:00:00 +0000
+++ crm_claim_rma_repair/i18n/crm_claim_rma_repair.pot	2014-04-15 22:17:58 +0000
@@ -0,0 +1,73 @@
+# Translation of OpenERP Server.
+# This file contains the translation of the following modules:
+#	* crm_claim_rma_repair
+#
+msgid ""
+msgstr ""
+"Project-Id-Version: OpenERP Server 7.0\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2014-04-15 21:55+0000\n"
+"PO-Revision-Date: 2014-04-15 21:55+0000\n"
+"Last-Translator: <>\n"
+"Language-Team: \n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: \n"
+"Plural-Forms: \n"
+
+#. module: crm_claim_rma_repair
+#: view:claim.make.repair:0
+msgid "Cancel"
+msgstr ""
+
+#. module: crm_claim_rma_repair
+#: field:claim.make.repair,claim_line_ids:0
+msgid "Claim Lines"
+msgstr ""
+
+#. module: crm_claim_rma_repair
+#: view:claim.make.repair:0
+msgid "Create Repair"
+msgstr ""
+
+#. module: crm_claim_rma_repair
+#: model:ir.model,name:crm_claim_rma_repair.model_claim_make_repair
+msgid "Generate Repair from CRM Claim RMA"
+msgstr ""
+
+#. module: crm_claim_rma_repair
+#: model:ir.model,name:crm_claim_rma_repair.model_claim_line
+msgid "List of product to return"
+msgstr ""
+
+#. module: crm_claim_rma_repair
+#: view:claim.make.repair:0
+#: model:ir.actions.act_window,name:crm_claim_rma_repair.action_claim_make_repair
+msgid "Make Repairs"
+msgstr ""
+
+#. module: crm_claim_rma_repair
+#: view:crm.claim:0
+msgid "New Repair"
+msgstr ""
+
+#. module: crm_claim_rma_repair
+#: field:claim.line,repair_id:0
+msgid "Repair"
+msgstr ""
+
+#. module: crm_claim_rma_repair
+#: model:ir.model,name:crm_claim_rma_repair.model_mrp_repair
+msgid "Repair Order"
+msgstr ""
+
+#. module: crm_claim_rma_repair
+#: view:claim.make.repair:0
+msgid "Select Lines to Repair"
+msgstr ""
+
+#. module: crm_claim_rma_repair
+#: view:claim.make.repair:0
+msgid "or"
+msgstr ""
+

=== added file 'crm_claim_rma_repair/i18n/fr.po'
--- crm_claim_rma_repair/i18n/fr.po	1970-01-01 00:00:00 +0000
+++ crm_claim_rma_repair/i18n/fr.po	2014-04-15 22:17:58 +0000
@@ -0,0 +1,73 @@
+# Translation of OpenERP Server.
+# This file contains the translation of the following modules:
+#	* crm_claim_rma_repair
+#
+msgid ""
+msgstr ""
+"Project-Id-Version: OpenERP Server 7.0\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2014-04-15 21:58+0000\n"
+"PO-Revision-Date: 2014-04-15 21:58+0000\n"
+"Last-Translator: Alexis de Lattre <alexis.delattre@xxxxxxxxxxxx>\n"
+"Language-Team: \n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: \n"
+"Plural-Forms: \n"
+
+#. module: crm_claim_rma_repair
+#: view:claim.make.repair:0
+msgid "Cancel"
+msgstr "Annuler"
+
+#. module: crm_claim_rma_repair
+#: field:claim.make.repair,claim_line_ids:0
+msgid "Claim Lines"
+msgstr "Lignes de RMA"
+
+#. module: crm_claim_rma_repair
+#: view:claim.make.repair:0
+msgid "Create Repair"
+msgstr "Créer une réparation"
+
+#. module: crm_claim_rma_repair
+#: model:ir.model,name:crm_claim_rma_repair.model_claim_make_repair
+msgid "Generate Repair from CRM Claim RMA"
+msgstr "Générer une réparation à partir d'un RMA"
+
+#. module: crm_claim_rma_repair
+#: model:ir.model,name:crm_claim_rma_repair.model_claim_line
+msgid "List of product to return"
+msgstr "Liste des produits à retourner"
+
+#. module: crm_claim_rma_repair
+#: view:claim.make.repair:0
+#: model:ir.actions.act_window,name:crm_claim_rma_repair.action_claim_make_repair
+msgid "Make Repairs"
+msgstr "Créer des réparations"
+
+#. module: crm_claim_rma_repair
+#: view:crm.claim:0
+msgid "New Repair"
+msgstr "Nouvelle réparation"
+
+#. module: crm_claim_rma_repair
+#: field:claim.line,repair_id:0
+msgid "Repair"
+msgstr "Réparation"
+
+#. module: crm_claim_rma_repair
+#: model:ir.model,name:crm_claim_rma_repair.model_mrp_repair
+msgid "Repair Order"
+msgstr "Ordre de réparation"
+
+#. module: crm_claim_rma_repair
+#: view:claim.make.repair:0
+msgid "Select Lines to Repair"
+msgstr "Sélectionner les lignes à réparer"
+
+#. module: crm_claim_rma_repair
+#: view:claim.make.repair:0
+msgid "or"
+msgstr "ou"
+

=== added directory 'crm_claim_rma_repair/wizard'
=== added file 'crm_claim_rma_repair/wizard/__init__.py'
--- crm_claim_rma_repair/wizard/__init__.py	1970-01-01 00:00:00 +0000
+++ crm_claim_rma_repair/wizard/__init__.py	2014-04-15 22:17:58 +0000
@@ -0,0 +1,23 @@
+# -*- encoding: utf-8 -*-
+##############################################################################
+#
+#    CRM Claim RMA Repair module for OpenERP
+#    Copyright (C) 2014 Akretion (http://www.akretion.com)
+#    @author Alexis de Lattre <alexis.delattre@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 . import claim_make_repair

=== added file 'crm_claim_rma_repair/wizard/claim_make_repair.py'
--- crm_claim_rma_repair/wizard/claim_make_repair.py	1970-01-01 00:00:00 +0000
+++ crm_claim_rma_repair/wizard/claim_make_repair.py	2014-04-15 22:17:58 +0000
@@ -0,0 +1,99 @@
+# -*- encoding: utf-8 -*-
+##############################################################################
+#
+#    CRM Claim RMA Repair module for OpenERP
+#    Copyright (C) 2014 Akretion (http://www.akretion.com)
+#    @author Alexis de Lattre <alexis.delattre@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, fields
+
+
+class claim_make_picking(orm.TransientModel):
+    _name = 'claim.make.repair'
+    _description = 'Generate Repair from CRM Claim RMA'
+
+    _columns = {
+        'claim_line_ids': fields.many2many(
+            'claim.line',
+            id1='claim_make_picking_id',
+            id2='claim_line_id',
+            string='Claim Lines'),
+        }
+
+    def _get_claim_lines(self, cr, uid, context=None):
+        if context is None:
+            context = {}
+        line_ids = self.pool['claim.line'].search(
+            cr, uid, [
+                ('claim_id', '=', context['active_id']),
+                ('repair_id', '=', False),
+            ],
+            context=context)
+        return line_ids
+
+    _defaults = {
+        'claim_line_ids': _get_claim_lines,
+        }
+
+    def _prepare_repair(self, cr, uid, claim, line, context=None):
+        partner_id = claim.partner_id and claim.partner_id.id or False
+        partner_on_change = self.pool['mrp.repair'].onchange_partner_id(
+            cr, uid, False, partner_id, False)
+        res = partner_on_change['value']
+        res.update({
+            'partner_id': partner_id,
+            'product_id': line.product_id.id,
+            'prodlot_id': line.prodlot_id and line.prodlot_id.id or False,
+            'company_id': claim.company_id.id,
+            'guarantee_limit': line.guarantee_limit,
+            'deliver_bool': False,  # Outgoing is managed by RMA
+        })
+        return res
+
+    def create_repair(self, cr, uid, ids, context=None):
+        if context is None:
+            context = {}
+        assert len(ids) == 1, 'Only one ID'
+        wizard = self.browse(cr, uid, ids[0], context=context)
+        claim = self.pool['crm.claim'].browse(
+            cr, uid, context['active_id'], context=context)
+        repair_ids = []
+        for line in wizard.claim_line_ids:
+            if line.repair_id:
+                continue
+            repair_id = self.pool['mrp.repair'].create(
+                cr, uid, self._prepare_repair(
+                    cr, uid, claim, line, context=context),
+                context=context)
+            repair_ids.append(repair_id)
+            line.write({'repair_id': repair_id}, context=context)
+
+        if not repair_ids:
+            return True
+
+        action_model, action_id = \
+            self.pool['ir.model.data'].get_object_reference(
+                cr, uid, 'mrp_repair', 'action_repair_order_tree')
+        assert action_model == 'ir.actions.act_window', 'Wrong model'
+        action = self.pool[action_model].read(
+            cr, uid, action_id, context=context)
+        action.update({
+            'target': 'current',
+            'domain': [('id', 'in', repair_ids)],
+            })
+        return action

=== added file 'crm_claim_rma_repair/wizard/claim_make_repair_view.xml'
--- crm_claim_rma_repair/wizard/claim_make_repair_view.xml	1970-01-01 00:00:00 +0000
+++ crm_claim_rma_repair/wizard/claim_make_repair_view.xml	2014-04-15 22:17:58 +0000
@@ -0,0 +1,39 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+  Copyright (C) 2014 Akretion
+  @author: Alexis de Lattre <alexis.delattre@xxxxxxxxxxxx>
+  The licence is in the file __openerp__.py
+-->
+<openerp>
+<data>
+
+
+<record id="claim_make_repair_form" model="ir.ui.view">
+    <field name="name">claim.make.repair.form</field>
+    <field name="model">claim.make.repair</field>
+    <field name="arch" type="xml">
+        <form string="Make Repairs" version="7.0">
+            <group name="repair-lines" string="Select Lines to Repair">
+                <field name="claim_line_ids" nolabel="1"/>
+            </group>
+            <footer>
+                <button name="create_repair" string="Create Repair"
+                    type="object" class="oe_highlight"/>
+                or
+                <button string="Cancel" class="oe_link" special="cancel"/>
+            </footer>
+        </form>
+    </field>
+</record>
+
+<record id="action_claim_make_repair" model="ir.actions.act_window">
+    <field name="name">Make Repairs</field>
+    <field name="res_model">claim.make.repair</field>
+    <field name="view_type">form</field>
+    <field name="view_mode">form</field>
+    <field name="target">new</field> 
+</record>
+
+
+</data>
+</openerp>


Follow ups