diff --git a/rma_repair/README.rst b/rma_repair/README.rst index 5151b42c..4e6b8a2c 100644 --- a/rma_repair/README.rst +++ b/rma_repair/README.rst @@ -5,10 +5,6 @@ RMA Repair ========== -wip: -* fix wizard -* change repair sequence to not use 'RMA'. - This module allows you to create repairs from one or more RMA lines. Installation @@ -22,7 +18,7 @@ Usage To create repairs from RMA lines: -#. Go to a approved RMA line. +#. Go to an approved RMA. #. Click on *Create Repair Order*. #. Fill the required information in the lines. #. Hit *Create Repair Orders*. diff --git a/rma_repair/models/rma_order_line.py b/rma_repair/models/rma_order_line.py index 00bfd78f..c88f2bb9 100644 --- a/rma_repair/models/rma_order_line.py +++ b/rma_repair/models/rma_order_line.py @@ -60,7 +60,13 @@ class RmaOrderLine(models.Model): def action_view_repair_order(self): action = self.env.ref('mrp_repair.action_repair_order_tree') result = action.read()[0] - result['domain'] = [('id', 'in', self.repair_ids.ids)] + repair_ids = self.repair_ids.ids + if len(repair_ids) != 1: + result['domain'] = [('id', 'in', repair_ids)] + elif len(repair_ids) == 1: + res = self.env.ref('mrp_repair.view_repair_order_form', False) + result['views'] = [(res and res.id or False, 'form')] + result['res_id'] = repair_ids[0] return result @api.multi diff --git a/rma_repair/wizards/rma_order_line_make_repair.py b/rma_repair/wizards/rma_order_line_make_repair.py index 79ac532b..b959252d 100644 --- a/rma_repair/wizards/rma_order_line_make_repair.py +++ b/rma_repair/wizards/rma_order_line_make_repair.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2016 Eficent Business and IT Consulting Services S.L. +# Copyright 2017 Eficent Business and IT Consulting Services S.L. # License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl-3.0). import openerp.addons.decimal_precision as dp @@ -31,10 +31,11 @@ class RmaLineMakeRepair(models.TransientModel): 'out_route_id': line.out_route_id.id, 'product_uom_id': line.uom_id.id, 'partner_id': line.partner_id.id, - # 'location_dest_id': which default here?, 'to_refurbish': to_refurbish, 'refurbish_product_id': refurbish_product_id, 'location_id': line.location_id.id, + 'location_dest_id': line.location_id.id, + 'invoice_method': 'after_repair' } @api.model @@ -95,32 +96,55 @@ class RmaLineMakeRepairItem(models.TransientModel): wiz_id = fields.Many2one( comodel_name='rma.order.line.make.repair', string='Wizard', - ondelete='cascade', readonly=True) + ondelete='cascade', readonly=True, + ) line_id = fields.Many2one( - comodel_name='rma.order.line', string='RMA Line', required=True) + comodel_name='rma.order.line', string='RMA', + required=True, readonly=True, + ) rma_id = fields.Many2one( comodel_name='rma.order', related='line_id.rma_id', - string='RMA Order', readonly=True) + string='RMA Order', readonly=True, + ) product_id = fields.Many2one( - comodel_name='product.product', string='Product', readonly=True) + comodel_name='product.product', string='Product', readonly=True, + ) product_qty = fields.Float( - string='Quantity to repair', digits=dp.get_precision('Product UoS')) + string='Quantity to repair', digits=dp.get_precision('Product UoS'), + ) product_uom_id = fields.Many2one( - comodel_name='product.uom', string='UoM', readonly=True) + comodel_name='product.uom', string='UoM', readonly=True, + ) out_route_id = fields.Many2one( comodel_name='stock.location.route', string='Outbound Route', - domain=[('rma_selectable', '=', True)]) + domain=[('rma_selectable', '=', True)], + ) partner_id = fields.Many2one( comodel_name='res.partner', string='Customer', required=False, - domain=[('customer', '=', True)]) + domain=[('customer', '=', True)], readonly=True, + ) location_id = fields.Many2one( - comodel_name="stock.location", string="Location", required=True) + comodel_name="stock.location", string="Location", required=True, + ) location_dest_id = fields.Many2one( comodel_name="stock.location", string="Destination location", - required=True) + required=True, + ) to_refurbish = fields.Boolean(string="To Refurbish?") refurbish_product_id = fields.Many2one( - comodel_name="product.product", string="Refurbished Product") + comodel_name="product.product", string="Refurbished Product", + ) + invoice_method = fields.Selection( + string="Invoice Method", selection=[ + ("none", "No Invoice"), + ("b4repair", "Before Repair"), + ("after_repair", "After Repair")], + required=True, + help="Selecting 'Before Repair' or 'After Repair' will allow you " + "to generate invoice before or after the repair is done " + "respectively. 'No invoice' means you don't want to generate " + "invoice for this repair order.", + ) @api.model def _prepare_repair_order(self, rma_line): @@ -140,4 +164,5 @@ class RmaLineMakeRepairItem(models.TransientModel): 'refurbish_location_dest_id': refurbish_location_dest_id, 'refurbish_product_id': self.refurbish_product_id.id, 'to_refurbish': self.to_refurbish, + 'invoice_method': self.invoice_method, } diff --git a/rma_repair/wizards/rma_order_line_make_repair_view.xml b/rma_repair/wizards/rma_order_line_make_repair_view.xml index 8a38aac3..2a1f0b84 100644 --- a/rma_repair/wizards/rma_order_line_make_repair_view.xml +++ b/rma_repair/wizards/rma_order_line_make_repair_view.xml @@ -23,6 +23,7 @@ +