[9.0][REW] rma_repair: adapt

This commit is contained in:
lreficent
2017-10-20 11:19:44 +02:00
committed by ahenriquez
parent b6657d8a3a
commit af9e1f1efb
4 changed files with 47 additions and 19 deletions

View File

@@ -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*.

View File

@@ -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

View File

@@ -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,
}

View File

@@ -23,6 +23,7 @@
<field name="refurbish_product_id" attrs="{'required': [('to_refurbish', '=', True)]}"/>
<field name="location_id"/>
<field name="location_dest_id"/>
<field name="invoice_method"/>
</tree>
</field>
</group>