Merge lp:~akretion-team/openerp-rma/add-crm-claim-rma-repair into lp:~openerprma/openerp-rma/7.0

Proposed by Alexis de Lattre
Status: Work in progress
Proposed branch: lp:~akretion-team/openerp-rma/add-crm-claim-rma-repair
Merge into: lp:~openerprma/openerp-rma/7.0
Prerequisite: lp:~akretion-team/openerp-rma/rma-cleanup-cleanup-cleanup
Diff against target: 518 lines (+471/-0)
9 files modified
crm_claim_rma_repair/__init__.py (+24/-0)
crm_claim_rma_repair/__openerp__.py (+46/-0)
crm_claim_rma_repair/crm_claim.py (+43/-0)
crm_claim_rma_repair/crm_claim_view.xml (+51/-0)
crm_claim_rma_repair/i18n/crm_claim_rma_repair.pot (+73/-0)
crm_claim_rma_repair/i18n/fr.po (+73/-0)
crm_claim_rma_repair/wizard/__init__.py (+23/-0)
crm_claim_rma_repair/wizard/claim_make_repair.py (+99/-0)
crm_claim_rma_repair/wizard/claim_make_repair_view.xml (+39/-0)
To merge this branch: bzr merge lp:~akretion-team/openerp-rma/add-crm-claim-rma-repair
Reviewer Review Type Date Requested Status
Benoit Guillot - http://www.akretion.com Approve
Alexandre Fayolle - camptocamp code review, no test Approve
Joël Grand-Guillaume @ camptocamp code review, no tests Approve
Review via email: mp+215976@code.launchpad.net

Description of the change

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'.

To post a comment you must log in.
Revision history for this message
Joël Grand-Guillaume @ camptocamp (jgrandguillaume-c2c) wrote :

Hi Alexis,

Thanks for that contrib. LGTM.

review: Approve (code review, no tests)
Revision history for this message
Alexandre Fayolle - camptocamp (alexandre-fayolle-c2c) wrote :

LGTM

review: Approve (code review, no test)
Revision history for this message
Benoit Guillot - http://www.akretion.com (benoit-guillot-z) wrote :

Ok for me

review: Approve
Revision history for this message
Joël Grand-Guillaume @ camptocamp (jgrandguillaume-c2c) wrote :

Unmerged revisions

73. By Alexis de Lattre

Add module crm_claim_rma_repair.

72. By Alexis de Lattre

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 ??)
Clean-up presentation in copyright headers and update licence to AGPL when needed
Remove dead code
Update views to v7.0 style
CLEAN UP CODE (and there is still A LOT to do in this area ! A LOT !)
Small changes to prepare the arrival of the modules crm_claim_rma_repair, crm_claim_rma_serial and product_serial_warranty.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added directory 'crm_claim_rma_repair'
2=== added file 'crm_claim_rma_repair/__init__.py'
3--- crm_claim_rma_repair/__init__.py 1970-01-01 00:00:00 +0000
4+++ crm_claim_rma_repair/__init__.py 2014-04-15 22:17:58 +0000
5@@ -0,0 +1,24 @@
6+# -*- encoding: utf-8 -*-
7+##############################################################################
8+#
9+# CRM Claim RMA Repair module for OpenERP
10+# Copyright (C) 2014 Akretion (http://www.akretion.com)
11+# @author Alexis de Lattre <alexis.delattre@akretion.com>
12+#
13+# This program is free software: you can redistribute it and/or modify
14+# it under the terms of the GNU Affero General Public License as
15+# published by the Free Software Foundation, either version 3 of the
16+# License, or (at your option) any later version.
17+#
18+# This program is distributed in the hope that it will be useful,
19+# but WITHOUT ANY WARRANTY; without even the implied warranty of
20+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21+# GNU Affero General Public License for more details.
22+#
23+# You should have received a copy of the GNU Affero General Public License
24+# along with this program. If not, see <http://www.gnu.org/licenses/>.
25+#
26+##############################################################################
27+
28+from . import wizard
29+from . import crm_claim
30
31=== added file 'crm_claim_rma_repair/__openerp__.py'
32--- crm_claim_rma_repair/__openerp__.py 1970-01-01 00:00:00 +0000
33+++ crm_claim_rma_repair/__openerp__.py 2014-04-15 22:17:58 +0000
34@@ -0,0 +1,46 @@
35+# -*- encoding: utf-8 -*-
36+##############################################################################
37+#
38+# CRM Claim RMA Repair extension module for OpenERP
39+# Copyright (C) 2014 Akretion (http://www.akretion.com)
40+# @author Alexis de Lattre <alexis.delattre@akretion.com>
41+#
42+# This program is free software: you can redistribute it and/or modify
43+# it under the terms of the GNU Affero General Public License as
44+# published by the Free Software Foundation, either version 3 of the
45+# License, or (at your option) any later version.
46+#
47+# This program is distributed in the hope that it will be useful,
48+# but WITHOUT ANY WARRANTY; without even the implied warranty of
49+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
50+# GNU Affero General Public License for more details.
51+#
52+# You should have received a copy of the GNU Affero General Public License
53+# along with this program. If not, see <http://www.gnu.org/licenses/>.
54+#
55+##############################################################################
56+
57+
58+{
59+ 'name': 'CRM Claim RMA Repair',
60+ 'version': '0.1',
61+ 'category': 'Customer Relationship Management',
62+ 'license': 'AGPL-3',
63+ 'summary': 'Connect crm_claim_rma with mrp_repair',
64+ 'description': """
65+CRM Claim RMA Repair
66+====================
67+
68+Add ability to create a repair from a CRM claim.
69+
70+Please contact Alexis de Lattre from Akretion <alexis.delattre@akretion.com> for any help or question about this module.
71+ """,
72+ 'author': 'Akretion',
73+ 'website': 'http://www.akretion.com',
74+ 'depends': ['mrp_repair', 'crm_claim_rma'],
75+ 'data': [
76+ 'wizard/claim_make_repair_view.xml',
77+ 'crm_claim_view.xml',
78+ ],
79+ 'active': False,
80+}
81
82=== added file 'crm_claim_rma_repair/crm_claim.py'
83--- crm_claim_rma_repair/crm_claim.py 1970-01-01 00:00:00 +0000
84+++ crm_claim_rma_repair/crm_claim.py 2014-04-15 22:17:58 +0000
85@@ -0,0 +1,43 @@
86+# -*- encoding: utf-8 -*-
87+##############################################################################
88+#
89+# CRM Claim RMA Repair module for OpenERP
90+# Copyright (C) 2014 Akretion (http://www.akretion.com)
91+# @author Alexis de Lattre <alexis.delattre@akretion.com>
92+#
93+# This program is free software: you can redistribute it and/or modify
94+# it under the terms of the GNU Affero General Public License as
95+# published by the Free Software Foundation, either version 3 of the
96+# License, or (at your option) any later version.
97+#
98+# This program is distributed in the hope that it will be useful,
99+# but WITHOUT ANY WARRANTY; without even the implied warranty of
100+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
101+# GNU Affero General Public License for more details.
102+#
103+# You should have received a copy of the GNU Affero General Public License
104+# along with this program. If not, see <http://www.gnu.org/licenses/>.
105+#
106+##############################################################################
107+
108+from openerp.osv import orm, fields
109+
110+
111+class claim_line(orm.Model):
112+ _inherit = 'claim.line'
113+
114+ _columns = {
115+ 'repair_id': fields.many2one('mrp.repair', 'Repair'),
116+ }
117+
118+
119+class mrp_repair(orm.Model):
120+ _inherit = "mrp.repair"
121+
122+ _columns = {
123+ # remove required=True on the native 'move_id' field
124+ 'move_id': fields.many2one(
125+ 'stock.move', 'Move', required=False,
126+ domain="[('product_id', '=', product_id)]", readonly=True,
127+ states={'draft': [('readonly', False)]}),
128+ }
129
130=== added file 'crm_claim_rma_repair/crm_claim_view.xml'
131--- crm_claim_rma_repair/crm_claim_view.xml 1970-01-01 00:00:00 +0000
132+++ crm_claim_rma_repair/crm_claim_view.xml 2014-04-15 22:17:58 +0000
133@@ -0,0 +1,51 @@
134+<?xml version="1.0" encoding="utf-8"?>
135+
136+<!--
137+ Copyright (C) 2014 Akretion (http://www.akretion.com/)
138+ @author Alexis de Lattre <alexis.delattre@akretion.com>
139+ The licence is in the file __openerp__.py
140+-->
141+
142+<openerp>
143+<data>
144+
145+
146+<record id="crm_claim_line_tree_view" model="ir.ui.view">
147+ <field name="name">repair.crm.claim.line.tree</field>
148+ <field name="model">claim.line</field>
149+ <field name="inherit_id" ref="crm_claim_rma.crm_claim_line_tree_view" />
150+ <field name="arch" type="xml">
151+ <field name="move_out_id" position="after">
152+ <field name="repair_id"/>
153+ </field>
154+ </field>
155+</record>
156+
157+<record id="crm_claim_line_form_view" model="ir.ui.view">
158+ <field name="name">repair.crm.claim.line.form</field>
159+ <field name="model">claim.line</field>
160+ <field name="inherit_id" ref="crm_claim_rma.crm_claim_line_form_view"/>
161+ <field name="arch" type="xml">
162+ <field name="move_out_id" position="after">
163+ <field name="repair_id"/>
164+ </field>
165+ </field>
166+</record>
167+
168+<record id="crm_claim_rma_form_view" model="ir.ui.view">
169+ <field name="name">repair.crm.claim.form</field>
170+ <field name="model">crm.claim</field>
171+ <field name="inherit_id" ref="crm_claim_rma.crm_case_claims_form_view"/>
172+ <field name="arch" type="xml">
173+ <group name="actions" position="attributes">
174+ <attribute name="col">6</attribute>
175+ </group>
176+ <group name="actions" position="inside">
177+ <button name="%(action_claim_make_repair)d" string="New Repair"
178+ type="action" states="open"/>
179+ </group>
180+ </field>
181+</record>
182+
183+</data>
184+</openerp>
185
186=== added directory 'crm_claim_rma_repair/i18n'
187=== added file 'crm_claim_rma_repair/i18n/crm_claim_rma_repair.pot'
188--- crm_claim_rma_repair/i18n/crm_claim_rma_repair.pot 1970-01-01 00:00:00 +0000
189+++ crm_claim_rma_repair/i18n/crm_claim_rma_repair.pot 2014-04-15 22:17:58 +0000
190@@ -0,0 +1,73 @@
191+# Translation of OpenERP Server.
192+# This file contains the translation of the following modules:
193+# * crm_claim_rma_repair
194+#
195+msgid ""
196+msgstr ""
197+"Project-Id-Version: OpenERP Server 7.0\n"
198+"Report-Msgid-Bugs-To: \n"
199+"POT-Creation-Date: 2014-04-15 21:55+0000\n"
200+"PO-Revision-Date: 2014-04-15 21:55+0000\n"
201+"Last-Translator: <>\n"
202+"Language-Team: \n"
203+"MIME-Version: 1.0\n"
204+"Content-Type: text/plain; charset=UTF-8\n"
205+"Content-Transfer-Encoding: \n"
206+"Plural-Forms: \n"
207+
208+#. module: crm_claim_rma_repair
209+#: view:claim.make.repair:0
210+msgid "Cancel"
211+msgstr ""
212+
213+#. module: crm_claim_rma_repair
214+#: field:claim.make.repair,claim_line_ids:0
215+msgid "Claim Lines"
216+msgstr ""
217+
218+#. module: crm_claim_rma_repair
219+#: view:claim.make.repair:0
220+msgid "Create Repair"
221+msgstr ""
222+
223+#. module: crm_claim_rma_repair
224+#: model:ir.model,name:crm_claim_rma_repair.model_claim_make_repair
225+msgid "Generate Repair from CRM Claim RMA"
226+msgstr ""
227+
228+#. module: crm_claim_rma_repair
229+#: model:ir.model,name:crm_claim_rma_repair.model_claim_line
230+msgid "List of product to return"
231+msgstr ""
232+
233+#. module: crm_claim_rma_repair
234+#: view:claim.make.repair:0
235+#: model:ir.actions.act_window,name:crm_claim_rma_repair.action_claim_make_repair
236+msgid "Make Repairs"
237+msgstr ""
238+
239+#. module: crm_claim_rma_repair
240+#: view:crm.claim:0
241+msgid "New Repair"
242+msgstr ""
243+
244+#. module: crm_claim_rma_repair
245+#: field:claim.line,repair_id:0
246+msgid "Repair"
247+msgstr ""
248+
249+#. module: crm_claim_rma_repair
250+#: model:ir.model,name:crm_claim_rma_repair.model_mrp_repair
251+msgid "Repair Order"
252+msgstr ""
253+
254+#. module: crm_claim_rma_repair
255+#: view:claim.make.repair:0
256+msgid "Select Lines to Repair"
257+msgstr ""
258+
259+#. module: crm_claim_rma_repair
260+#: view:claim.make.repair:0
261+msgid "or"
262+msgstr ""
263+
264
265=== added file 'crm_claim_rma_repair/i18n/fr.po'
266--- crm_claim_rma_repair/i18n/fr.po 1970-01-01 00:00:00 +0000
267+++ crm_claim_rma_repair/i18n/fr.po 2014-04-15 22:17:58 +0000
268@@ -0,0 +1,73 @@
269+# Translation of OpenERP Server.
270+# This file contains the translation of the following modules:
271+# * crm_claim_rma_repair
272+#
273+msgid ""
274+msgstr ""
275+"Project-Id-Version: OpenERP Server 7.0\n"
276+"Report-Msgid-Bugs-To: \n"
277+"POT-Creation-Date: 2014-04-15 21:58+0000\n"
278+"PO-Revision-Date: 2014-04-15 21:58+0000\n"
279+"Last-Translator: Alexis de Lattre <alexis.delattre@akretion.com>\n"
280+"Language-Team: \n"
281+"MIME-Version: 1.0\n"
282+"Content-Type: text/plain; charset=UTF-8\n"
283+"Content-Transfer-Encoding: \n"
284+"Plural-Forms: \n"
285+
286+#. module: crm_claim_rma_repair
287+#: view:claim.make.repair:0
288+msgid "Cancel"
289+msgstr "Annuler"
290+
291+#. module: crm_claim_rma_repair
292+#: field:claim.make.repair,claim_line_ids:0
293+msgid "Claim Lines"
294+msgstr "Lignes de RMA"
295+
296+#. module: crm_claim_rma_repair
297+#: view:claim.make.repair:0
298+msgid "Create Repair"
299+msgstr "Créer une réparation"
300+
301+#. module: crm_claim_rma_repair
302+#: model:ir.model,name:crm_claim_rma_repair.model_claim_make_repair
303+msgid "Generate Repair from CRM Claim RMA"
304+msgstr "Générer une réparation à partir d'un RMA"
305+
306+#. module: crm_claim_rma_repair
307+#: model:ir.model,name:crm_claim_rma_repair.model_claim_line
308+msgid "List of product to return"
309+msgstr "Liste des produits à retourner"
310+
311+#. module: crm_claim_rma_repair
312+#: view:claim.make.repair:0
313+#: model:ir.actions.act_window,name:crm_claim_rma_repair.action_claim_make_repair
314+msgid "Make Repairs"
315+msgstr "Créer des réparations"
316+
317+#. module: crm_claim_rma_repair
318+#: view:crm.claim:0
319+msgid "New Repair"
320+msgstr "Nouvelle réparation"
321+
322+#. module: crm_claim_rma_repair
323+#: field:claim.line,repair_id:0
324+msgid "Repair"
325+msgstr "Réparation"
326+
327+#. module: crm_claim_rma_repair
328+#: model:ir.model,name:crm_claim_rma_repair.model_mrp_repair
329+msgid "Repair Order"
330+msgstr "Ordre de réparation"
331+
332+#. module: crm_claim_rma_repair
333+#: view:claim.make.repair:0
334+msgid "Select Lines to Repair"
335+msgstr "Sélectionner les lignes à réparer"
336+
337+#. module: crm_claim_rma_repair
338+#: view:claim.make.repair:0
339+msgid "or"
340+msgstr "ou"
341+
342
343=== added directory 'crm_claim_rma_repair/wizard'
344=== added file 'crm_claim_rma_repair/wizard/__init__.py'
345--- crm_claim_rma_repair/wizard/__init__.py 1970-01-01 00:00:00 +0000
346+++ crm_claim_rma_repair/wizard/__init__.py 2014-04-15 22:17:58 +0000
347@@ -0,0 +1,23 @@
348+# -*- encoding: utf-8 -*-
349+##############################################################################
350+#
351+# CRM Claim RMA Repair module for OpenERP
352+# Copyright (C) 2014 Akretion (http://www.akretion.com)
353+# @author Alexis de Lattre <alexis.delattre@akretion.com>
354+#
355+# This program is free software: you can redistribute it and/or modify
356+# it under the terms of the GNU Affero General Public License as
357+# published by the Free Software Foundation, either version 3 of the
358+# License, or (at your option) any later version.
359+#
360+# This program is distributed in the hope that it will be useful,
361+# but WITHOUT ANY WARRANTY; without even the implied warranty of
362+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
363+# GNU Affero General Public License for more details.
364+#
365+# You should have received a copy of the GNU Affero General Public License
366+# along with this program. If not, see <http://www.gnu.org/licenses/>.
367+#
368+##############################################################################
369+
370+from . import claim_make_repair
371
372=== added file 'crm_claim_rma_repair/wizard/claim_make_repair.py'
373--- crm_claim_rma_repair/wizard/claim_make_repair.py 1970-01-01 00:00:00 +0000
374+++ crm_claim_rma_repair/wizard/claim_make_repair.py 2014-04-15 22:17:58 +0000
375@@ -0,0 +1,99 @@
376+# -*- encoding: utf-8 -*-
377+##############################################################################
378+#
379+# CRM Claim RMA Repair module for OpenERP
380+# Copyright (C) 2014 Akretion (http://www.akretion.com)
381+# @author Alexis de Lattre <alexis.delattre@akretion.com>
382+#
383+# This program is free software: you can redistribute it and/or modify
384+# it under the terms of the GNU Affero General Public License as
385+# published by the Free Software Foundation, either version 3 of the
386+# License, or (at your option) any later version.
387+#
388+# This program is distributed in the hope that it will be useful,
389+# but WITHOUT ANY WARRANTY; without even the implied warranty of
390+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
391+# GNU Affero General Public License for more details.
392+#
393+# You should have received a copy of the GNU Affero General Public License
394+# along with this program. If not, see <http://www.gnu.org/licenses/>.
395+#
396+##############################################################################
397+
398+from openerp.osv import orm, fields
399+
400+
401+class claim_make_picking(orm.TransientModel):
402+ _name = 'claim.make.repair'
403+ _description = 'Generate Repair from CRM Claim RMA'
404+
405+ _columns = {
406+ 'claim_line_ids': fields.many2many(
407+ 'claim.line',
408+ id1='claim_make_picking_id',
409+ id2='claim_line_id',
410+ string='Claim Lines'),
411+ }
412+
413+ def _get_claim_lines(self, cr, uid, context=None):
414+ if context is None:
415+ context = {}
416+ line_ids = self.pool['claim.line'].search(
417+ cr, uid, [
418+ ('claim_id', '=', context['active_id']),
419+ ('repair_id', '=', False),
420+ ],
421+ context=context)
422+ return line_ids
423+
424+ _defaults = {
425+ 'claim_line_ids': _get_claim_lines,
426+ }
427+
428+ def _prepare_repair(self, cr, uid, claim, line, context=None):
429+ partner_id = claim.partner_id and claim.partner_id.id or False
430+ partner_on_change = self.pool['mrp.repair'].onchange_partner_id(
431+ cr, uid, False, partner_id, False)
432+ res = partner_on_change['value']
433+ res.update({
434+ 'partner_id': partner_id,
435+ 'product_id': line.product_id.id,
436+ 'prodlot_id': line.prodlot_id and line.prodlot_id.id or False,
437+ 'company_id': claim.company_id.id,
438+ 'guarantee_limit': line.guarantee_limit,
439+ 'deliver_bool': False, # Outgoing is managed by RMA
440+ })
441+ return res
442+
443+ def create_repair(self, cr, uid, ids, context=None):
444+ if context is None:
445+ context = {}
446+ assert len(ids) == 1, 'Only one ID'
447+ wizard = self.browse(cr, uid, ids[0], context=context)
448+ claim = self.pool['crm.claim'].browse(
449+ cr, uid, context['active_id'], context=context)
450+ repair_ids = []
451+ for line in wizard.claim_line_ids:
452+ if line.repair_id:
453+ continue
454+ repair_id = self.pool['mrp.repair'].create(
455+ cr, uid, self._prepare_repair(
456+ cr, uid, claim, line, context=context),
457+ context=context)
458+ repair_ids.append(repair_id)
459+ line.write({'repair_id': repair_id}, context=context)
460+
461+ if not repair_ids:
462+ return True
463+
464+ action_model, action_id = \
465+ self.pool['ir.model.data'].get_object_reference(
466+ cr, uid, 'mrp_repair', 'action_repair_order_tree')
467+ assert action_model == 'ir.actions.act_window', 'Wrong model'
468+ action = self.pool[action_model].read(
469+ cr, uid, action_id, context=context)
470+ action.update({
471+ 'target': 'current',
472+ 'domain': [('id', 'in', repair_ids)],
473+ })
474+ return action
475
476=== added file 'crm_claim_rma_repair/wizard/claim_make_repair_view.xml'
477--- crm_claim_rma_repair/wizard/claim_make_repair_view.xml 1970-01-01 00:00:00 +0000
478+++ crm_claim_rma_repair/wizard/claim_make_repair_view.xml 2014-04-15 22:17:58 +0000
479@@ -0,0 +1,39 @@
480+<?xml version="1.0" encoding="utf-8"?>
481+<!--
482+ Copyright (C) 2014 Akretion
483+ @author: Alexis de Lattre <alexis.delattre@akretion.com>
484+ The licence is in the file __openerp__.py
485+-->
486+<openerp>
487+<data>
488+
489+
490+<record id="claim_make_repair_form" model="ir.ui.view">
491+ <field name="name">claim.make.repair.form</field>
492+ <field name="model">claim.make.repair</field>
493+ <field name="arch" type="xml">
494+ <form string="Make Repairs" version="7.0">
495+ <group name="repair-lines" string="Select Lines to Repair">
496+ <field name="claim_line_ids" nolabel="1"/>
497+ </group>
498+ <footer>
499+ <button name="create_repair" string="Create Repair"
500+ type="object" class="oe_highlight"/>
501+ or
502+ <button string="Cancel" class="oe_link" special="cancel"/>
503+ </footer>
504+ </form>
505+ </field>
506+</record>
507+
508+<record id="action_claim_make_repair" model="ir.actions.act_window">
509+ <field name="name">Make Repairs</field>
510+ <field name="res_model">claim.make.repair</field>
511+ <field name="view_type">form</field>
512+ <field name="view_mode">form</field>
513+ <field name="target">new</field>
514+</record>
515+
516+
517+</data>
518+</openerp>

Subscribers

People subscribed via source and target branches