From c3141880dbb9763c728fbf896b56c2144fcaf72a Mon Sep 17 00:00:00 2001 From: David Date: Wed, 23 Jan 2019 12:07:55 +0100 Subject: [PATCH] [FIX] pos_order_return: return picking and invoices --- pos_order_return/i18n/es.po | 6 ++++++ pos_order_return/models/pos_order.py | 11 +++++++---- pos_order_return/tests/test_pos_order_return.py | 2 ++ 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/pos_order_return/i18n/es.po b/pos_order_return/i18n/es.po index 6ff8c434..e2326887 100644 --- a/pos_order_return/i18n/es.po +++ b/pos_order_return/i18n/es.po @@ -178,6 +178,12 @@ msgstr "Botella retornable" msgid "Returnable Quantity" msgstr "Cantidad retornable" +#. module: pos_order_return +#: code:addons/pos_order_return/models/pos_order.py:55 +#, python-format +msgid "Return of %s" +msgstr "DevoluciĆ³n de %s" + #. module: pos_order_return #: model:ir.model.fields,field_description:pos_order_return.field_pos_order_line_returned_line_id #: model:ir.model.fields,field_description:pos_order_return.field_pos_order_returned_order_id diff --git a/pos_order_return/models/pos_order.py b/pos_order_return/models/pos_order.py index bc35b172..68dd7578 100644 --- a/pos_order_return/models/pos_order.py +++ b/pos_order_return/models/pos_order.py @@ -48,11 +48,12 @@ class PosOrder(models.Model): def _prepare_invoice(self): res = super(PosOrder, self)._prepare_invoice() - if not self.returned_order_id: + if not self.returned_order_id.invoice_id: return res res.update({ - 'origin': self.name, - 'type': 'out_refund', + 'origin': self.returned_order_id.invoice_id.number, + 'name': _( + 'Return of %s' % self.returned_order_id.invoice_id.number), 'refund_invoice_id': self.returned_order_id.invoice_id.id, }) return res @@ -95,9 +96,10 @@ class PosOrder(models.Model): return res def action_pos_order_paid(self): + res = super(PosOrder, self).action_pos_order_paid() if self.returned_order_id and self.returned_order_id.invoice_id: self._action_pos_order_invoice() - return super(PosOrder, self).action_pos_order_paid() + return res def _create_picking_return(self): self.ensure_one() @@ -129,6 +131,7 @@ class PosOrder(models.Model): wizard = order._create_picking_return() res = wizard.create_returns() order.write({'picking_id': res['res_id']}) + order._force_picking_done(order.picking_id) return res diff --git a/pos_order_return/tests/test_pos_order_return.py b/pos_order_return/tests/test_pos_order_return.py index ecd8da95..a2a657a7 100644 --- a/pos_order_return/tests/test_pos_order_return.py +++ b/pos_order_return/tests/test_pos_order_return.py @@ -78,6 +78,7 @@ class TestPOSOrderReturn(common.HttpCase): # Partner balance is 0 self.assertEqual(sum( self.partner.mapped('invoice_ids.amount_total_signed')), 0) + self.assertEqual(self.pos_order.picking_id.state, 'done') def test_pos_order_partial_refund(self): partial_refund = self.env['pos.partial.return.wizard'].with_context({ @@ -100,3 +101,4 @@ class TestPOSOrderReturn(common.HttpCase): # Partner balance is 1350 self.assertEqual(sum( self.partner.mapped('invoice_ids.amount_total_signed')), 1350) + self.assertEqual(self.pos_order.picking_id.state, 'done')