Browse Source

[FIX] pos_order_return: return picking and invoices

pull/323/head
David 6 years ago
parent
commit
9dd1e033a0
  1. 6
      pos_order_return/i18n/es.po
  2. 11
      pos_order_return/models/pos_order.py
  3. 2
      pos_order_return/tests/test_pos_order_return.py

6
pos_order_return/i18n/es.po

@ -178,6 +178,12 @@ msgstr "Botella retornable"
msgid "Returnable Quantity" msgid "Returnable Quantity"
msgstr "Cantidad retornable" 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 #. 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_line_returned_line_id
#: model:ir.model.fields,field_description:pos_order_return.field_pos_order_returned_order_id #: model:ir.model.fields,field_description:pos_order_return.field_pos_order_returned_order_id

11
pos_order_return/models/pos_order.py

@ -48,11 +48,12 @@ class PosOrder(models.Model):
def _prepare_invoice(self): def _prepare_invoice(self):
res = super(PosOrder, self)._prepare_invoice() res = super(PosOrder, self)._prepare_invoice()
if not self.returned_order_id:
if not self.returned_order_id.invoice_id:
return res return res
res.update({ 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, 'refund_invoice_id': self.returned_order_id.invoice_id.id,
}) })
return res return res
@ -95,9 +96,10 @@ class PosOrder(models.Model):
return res return res
def action_pos_order_paid(self): 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: if self.returned_order_id and self.returned_order_id.invoice_id:
self._action_pos_order_invoice() self._action_pos_order_invoice()
return super(PosOrder, self).action_pos_order_paid()
return res
def _create_picking_return(self): def _create_picking_return(self):
self.ensure_one() self.ensure_one()
@ -129,6 +131,7 @@ class PosOrder(models.Model):
wizard = order._create_picking_return() wizard = order._create_picking_return()
res = wizard.create_returns() res = wizard.create_returns()
order.write({'picking_id': res['res_id']}) order.write({'picking_id': res['res_id']})
order._force_picking_done(order.picking_id)
return res return res

2
pos_order_return/tests/test_pos_order_return.py

@ -78,6 +78,7 @@ class TestPOSOrderReturn(common.HttpCase):
# Partner balance is 0 # Partner balance is 0
self.assertEqual(sum( self.assertEqual(sum(
self.partner.mapped('invoice_ids.amount_total_signed')), 0) 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): def test_pos_order_partial_refund(self):
partial_refund = self.env['pos.partial.return.wizard'].with_context({ partial_refund = self.env['pos.partial.return.wizard'].with_context({
@ -100,3 +101,4 @@ class TestPOSOrderReturn(common.HttpCase):
# Partner balance is 1350 # Partner balance is 1350
self.assertEqual(sum( self.assertEqual(sum(
self.partner.mapped('invoice_ids.amount_total_signed')), 1350) self.partner.mapped('invoice_ids.amount_total_signed')), 1350)
self.assertEqual(self.pos_order.picking_id.state, 'done')
Loading…
Cancel
Save