Skip to content

Commit

Permalink
[MIG] stock_picking_return_refund_option: Migration to 15.0
Browse files Browse the repository at this point in the history
  • Loading branch information
cesar-tecnativa committed Jul 13, 2022
1 parent 425c8d2 commit 2b2ee37
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 13 deletions.
2 changes: 1 addition & 1 deletion stock_picking_return_refund_option/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
{
"name": "Stock Picking Return Refund Option",
"summary": "Update the refund options in pickings",
"version": "13.0.1.0.2",
"version": "15.0.1.0.0",
"development_status": "Production/Stable",
"category": "Sales",
"website": "https://github.com/OCA/account-invoicing",
Expand Down
5 changes: 3 additions & 2 deletions stock_picking_return_refund_option/models/stock_move.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ def write(self, vals):
res = super().write(vals)
if "to_refund" in vals:
for move in self:
move.picking_id.set_delivered_qty()
move.picking_id.set_received_qty()
if move.picking_id:
move.picking_id.set_delivered_qty()
move.picking_id.set_received_qty()
return res
6 changes: 2 additions & 4 deletions stock_picking_return_refund_option/models/stock_picking.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,8 @@ def _inverse_to_refund_lines(self):

def _compute_is_return(self):
for picking in self:
if any(x.origin_returned_move_id for x in picking.move_lines):
picking.is_return = True
else:
picking.is_return = False
picking.is_return = any(x.origin_returned_move_id for x in picking.move_lines)


def _update_stock_moves(self):
for pick in self.filtered("to_refund_lines"):
Expand Down
5 changes: 4 additions & 1 deletion stock_picking_return_refund_option/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
* Sergio Teruel <[email protected]>
* `Tecnativa <https://www.tecnativa.com>`_:

* Sergio Teruel
* César A. Sánchez
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def setUpClass(cls):
move_line_vals["qty_done"] = 1
move_line_vals_list.append(move_line_vals)
cls.env["stock.move.line"].create(move_line_vals_list)
cls.picking.action_done()
cls.picking.button_validate()
cls.order._create_invoices()

def get_return_picking_wizard(self, picking):
Expand All @@ -56,7 +56,7 @@ def test_return_to_refund_values(self):
return_wizard = self.return_picking_wiz(self.picking)
return_pick = self.picking.browse(return_wizard.create_returns()["res_id"])
return_pick.move_line_ids.write({"qty_done": 1.0})
return_pick.action_done()
return_pick.button_validate()
self.assertEqual(return_pick.to_refund_lines, "no_refund")
return_pick.move_lines.write({"to_refund": True})
self.assertEqual(return_pick.to_refund_lines, "to_refund")
Expand All @@ -68,7 +68,7 @@ def test_return_so_wo_to_refund(self):
return_wizard = self.return_picking_wiz(self.picking)
return_pick = self.picking.browse(return_wizard.create_returns()["res_id"])
return_pick.move_line_ids.write({"qty_done": 1.0})
return_pick.action_done()
return_pick.button_validate()
self.assertEqual(self.order.invoice_status, "invoiced")

return_pick.to_refund_lines = "to_refund"
Expand Down Expand Up @@ -96,15 +96,15 @@ def test_return_po_wo_to_refund(self):
move_line_vals = picking.move_lines._prepare_move_line_vals()
move_line_vals["qty_done"] = 1
self.env["stock.move.line"].create(move_line_vals)
picking.action_done()
picking.button_validate()
self.assertEqual(po_order.invoice_status, "to invoice")
# Return the picking without refund
return_wizard = self.return_picking_wiz(picking)
return_pick = self.picking.browse(return_wizard.create_returns()["res_id"])
move_line_vals = return_pick.move_lines._prepare_move_line_vals()
move_line_vals["qty_done"] = 1
self.env["stock.move.line"].create(move_line_vals)
return_pick.action_done()
return_pick.button_validate()
# Now set to be refunded
return_pick.to_refund_lines = "to_refund"
self.assertEqual(po_order.invoice_status, "no")
Expand Down

0 comments on commit 2b2ee37

Please sign in to comment.