Skip to content

Commit

Permalink
[MIG] stock_picking_return_refund_option: Migration to 18.0
Browse files Browse the repository at this point in the history
  • Loading branch information
CarlosRoca13 committed Feb 28, 2025
1 parent c3869f9 commit 24846d6
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 28 deletions.
1 change: 1 addition & 0 deletions stock_picking_return_refund_option/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ Contributors

- Sergio Teruel
- César A. Sánchez
- Carlos Roca

Maintainers
-----------
Expand Down
4 changes: 2 additions & 2 deletions stock_picking_return_refund_option/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
{
"name": "Stock Picking Return Refund Option",
"summary": "Update the refund options in pickings",
"version": "16.0.1.0.2",
"version": "18.0.1.0.0",
"development_status": "Production/Stable",
"category": "Sales",
"website": "https://github.com/OCA/account-invoicing",
"author": "Tecnativa, " "Odoo Community Association (OCA)",
"author": "Tecnativa, Odoo Community Association (OCA)",
"license": "AGPL-3",
"application": False,
"installable": True,
Expand Down
1 change: 1 addition & 0 deletions stock_picking_return_refund_option/readme/CONTRIBUTORS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
- [Tecnativa](https://www.tecnativa.com):
- Sergio Teruel
- César A. Sánchez
- Carlos Roca
Original file line number Diff line number Diff line change
Expand Up @@ -465,6 +465,7 @@ <h2><a class="toc-backref" href="#toc-entry-6">Contributors</a></h2>
<li><a class="reference external" href="https://www.tecnativa.com">Tecnativa</a>:<ul>
<li>Sergio Teruel</li>
<li>César A. Sánchez</li>
<li>Carlos Roca</li>
</ul>
</li>
</ul>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Copyright 2018 Tecnativa - Sergio Teruel
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
from odoo.tests.common import Form, TransactionCase, tagged
from odoo.tests import Form
from odoo.tests.common import TransactionCase, tagged


@tagged("post_install", "-at_install")
Expand All @@ -18,23 +19,24 @@ def setUpClass(cls):
tracking_disable=True,
)
)
if not cls.env.company.chart_template_id:
# Load a CoA if there's none in current company
coa = cls.env.ref("l10n_generic_coa.configurable_chart_template", False)
if not coa:
# Load the first available CoA
coa = cls.env["account.chart.template"].search(
[("visible", "=", True)], limit=1
)
coa.try_loading(company=cls.env.company, install_demo=False)
cls.partner = cls.env["res.partner"].create(
{"name": "Test", "customer_rank": 1, "supplier_rank": 1}
)
cls.product = cls.env["product.product"].create(
{"name": "test_product", "type": "product", "invoice_policy": "delivery"}
{
"name": "test_product",
"type": "consu",
"is_storable": True,
"invoice_policy": "delivery",
}
)
cls.product2 = cls.env["product.product"].create(
{"name": "test_product_2", "type": "product", "invoice_policy": "delivery"}
{
"name": "test_product_2",
"type": "consu",
"is_storable": True,
"invoice_policy": "delivery",
}
)
with Form(cls.env["sale.order"]) as order_form:
order_form.partner_id = cls.partner
Expand All @@ -50,7 +52,7 @@ def setUpClass(cls):
move_line_vals_list = []
for move in cls.picking.move_ids:
move_line_vals = move._prepare_move_line_vals()
move_line_vals["qty_done"] = 1
move_line_vals["quantity"] = 1
move_line_vals_list.append(move_line_vals)
cls.env["stock.move.line"].create(move_line_vals_list)
cls.picking.button_validate()
Expand All @@ -73,8 +75,10 @@ def return_picking_wiz(self, picking):

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 = self.picking.browse(
return_wizard.action_create_returns()["res_id"]
)
return_pick.move_line_ids.write({"quantity": 1.0})
return_pick.button_validate()
self.assertEqual(return_pick.to_refund_lines, "no_refund")
return_pick.move_ids.write({"to_refund": True})
Expand All @@ -85,8 +89,10 @@ def test_return_to_refund_values(self):
def test_return_so_wo_to_refund(self):
# Return some items, after SO was invoiced
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 = self.picking.browse(
return_wizard.action_create_returns()["res_id"]
)
return_pick.move_line_ids.write({"quantity": 1.0})
return_pick.button_validate()
self.assertEqual(self.order.invoice_status, "invoiced")

Expand All @@ -113,15 +119,17 @@ def test_return_po_wo_to_refund(self):
po_order.button_confirm()
picking = po_order.picking_ids[:]
move_line_vals = picking.move_ids._prepare_move_line_vals()
move_line_vals["qty_done"] = 1
move_line_vals["quantity"] = 1
self.env["stock.move.line"].create(move_line_vals)
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"])
return_pick = self.picking.browse(
return_wizard.action_create_returns()["res_id"]
)
move_line_vals = return_pick.move_ids._prepare_move_line_vals()
move_line_vals["qty_done"] = 1
move_line_vals["quantity"] = 1
self.env["stock.move.line"].create(move_line_vals)
return_pick.button_validate()
# Now set to be refunded
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,16 @@
<field name="is_return" invisible="1" />
<field
name="to_refund_lines"
attrs="{'invisible': [('is_return', '=', False)]}"
invisible="not is_return"
string="Refund Options"
/>
</xpath>
<!-- Make visible to_refund field at operations (stock moves) level -->
<xpath
expr="//field[@name='move_ids_without_package']/tree"
expr="//field[@name='move_ids_without_package']/list"
position="inside"
>
<field
name="to_refund"
attrs="{'column_invisible': [('parent.is_return', '=', False)]}"
/>
<field name="to_refund" column_invisible="not parent.is_return" />
</xpath>
</field>
</record>
Expand Down

0 comments on commit 24846d6

Please sign in to comment.