diff --git a/rma_repair/__manifest__.py b/rma_repair/__manifest__.py
index ff01690c..aff5ec3c 100644
--- a/rma_repair/__manifest__.py
+++ b/rma_repair/__manifest__.py
@@ -3,7 +3,7 @@
{
"name": "RMA Repair",
- "version": "12.0.1.2.0",
+ "version": "12.0.1.2.1",
"license": "LGPL-3",
"category": "RMA",
"summary": "Links RMA with Repairs.",
diff --git a/rma_repair/models/rma_order_line.py b/rma_repair/models/rma_order_line.py
index 4f577ddd..7768e1e0 100644
--- a/rma_repair/models/rma_order_line.py
+++ b/rma_repair/models/rma_order_line.py
@@ -142,6 +142,10 @@ class RmaOrderLine(models.Model):
def _compute_qty_to_deliver(self):
res = super(RmaOrderLine, self)._compute_qty_to_deliver()
for rec in self.filtered(lambda l: l.delivery_policy == 'repair'):
- rec.qty_to_deliver = rec.qty_repaired - rec.qty_delivered - \
- rec.qty_to_pay
+ rec.qty_to_deliver = rec.qty_repaired - rec.qty_delivered
+ return res
+
+ def rma_repair_make_invoice(self):
+ res = self.env['repair.order.make_invoice'].with_context(
+ active_ids=self.repair_ids.ids).create({'group': True}).make_invoices()
return res
diff --git a/rma_repair/tests/test_rma_repair.py b/rma_repair/tests/test_rma_repair.py
index a1b2a537..a36661a4 100644
--- a/rma_repair/tests/test_rma_repair.py
+++ b/rma_repair/tests/test_rma_repair.py
@@ -242,7 +242,7 @@ class TestRmaRepair(common.SingleTransactionCase):
repair.action_repair_invoice_create()
self.assertEqual(rma.qty_repaired, 1.0)
repair.invoice_id.action_invoice_open()
- self.assertEqual(rma.qty_to_deliver, 0.0)
+ self.assertEqual(rma.qty_to_deliver, 1.0)
repair.invoice_id.pay_and_reconcile(self.bank_journal, 200.0)
self.assertEqual(repair.invoice_status, 'paid')
self.assertEqual(rma.qty_to_pay, 0.0)
diff --git a/rma_repair/views/rma_order_line_view.xml b/rma_repair/views/rma_order_line_view.xml
index d9a5f5a2..1ad0e4bd 100644
--- a/rma_repair/views/rma_order_line_view.xml
+++ b/rma_repair/views/rma_order_line_view.xml
@@ -45,8 +45,25 @@
string="Create Repair Order"
class="oe_highlight"
type="action"/>
+
+
+ Create Repair Invoices
+ ir.actions.act_window
+ repair.order.make_invoice
+ form
+ form
+ new
+
+
+
diff --git a/rma_repair/wizards/__init__.py b/rma_repair/wizards/__init__.py
index 29cb35b3..521029a1 100644
--- a/rma_repair/wizards/__init__.py
+++ b/rma_repair/wizards/__init__.py
@@ -1,3 +1,4 @@
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html)
from . import rma_order_line_make_repair
+from . import repair_make_invoice
diff --git a/rma_repair/wizards/repair_make_invoice.py b/rma_repair/wizards/repair_make_invoice.py
new file mode 100644
index 00000000..090ffec6
--- /dev/null
+++ b/rma_repair/wizards/repair_make_invoice.py
@@ -0,0 +1,17 @@
+# Copyright 2017 Eficent Business and IT Consulting Services S.L.
+# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl-3.0).
+
+from odoo import api, models
+
+
+class MakeInvoice(models.TransientModel):
+ _inherit = 'repair.order.make_invoice'
+
+ @api.multi
+ def make_invoices(self):
+ if self._context.get('active_model') == 'rma.order.line':
+ rma_lines = self.env['rma.order.line'].browse(
+ self._context.get('active_ids'))
+ self = self.with_context(
+ active_ids=rma_lines.mapped('repair_ids').ids)
+ return super().make_invoices()