Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[16.0][OU-FIX] rma: Improve migration script to create picking types (only if not set) #396

Merged
merged 1 commit into from
Jun 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions rma/migrations/16.0.1.4.0/post-migration.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,8 @@ def migrate(env, version):
warehouses = env["stock.warehouse"].search([])
warehouses = warehouses.with_context(rma_post_init_hook=True)
for wh in warehouses:
if not wh.rma_in_type_id or not wh.rma_out_type_id:
data = wh._create_or_update_sequences_and_picking_types()
wh.write(data)
route_vals = wh._create_or_update_route()
wh.write(route_vals)
13 changes: 7 additions & 6 deletions rma/models/stock_warehouse.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,12 +123,13 @@

def _get_picking_type_update_values(self):
data = super()._get_picking_type_update_values()
data.update(
{
"rma_in_type_id": {"default_location_dest_id": self.rma_loc_id.id},
"rma_out_type_id": {"default_location_src_id": self.rma_loc_id.id},
}
)
picking_types = {
"rma_in_type_id": {"default_location_dest_id": self.rma_loc_id.id},
"rma_out_type_id": {"default_location_src_id": self.rma_loc_id.id},
}
if self.env.context.get("rma_post_init_hook"):
return picking_types

Check warning on line 131 in rma/models/stock_warehouse.py

View check run for this annotation

Codecov / codecov/patch

rma/models/stock_warehouse.py#L131

Added line #L131 was not covered by tests
data.update(picking_types)
return data

def _create_or_update_sequences_and_picking_types(self):
Expand Down
2 changes: 2 additions & 0 deletions rma/tests/test_rma.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

from odoo.exceptions import UserError, ValidationError
from odoo.tests import Form, TransactionCase, new_test_user, users
from odoo.tools import mute_logger

from .. import hooks

Expand Down Expand Up @@ -761,6 +762,7 @@ def test_split(self):
self.assertEqual(new_rma.move_id.quantity_done, 10)
self.assertEqual(new_rma.reception_move_id.quantity_done, 10)

@mute_logger("odoo.models.unlink")
def test_rma_to_receive_on_delete_invoice(self):
rma = self._create_confirm_receive(self.partner, self.product, 10, self.rma_loc)
rma.action_refund()
Expand Down
Loading