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

[15.0][IMP] RMA - refactor to use procurement run #384

Closed
wants to merge 4 commits into from
Closed
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: 2 additions & 1 deletion rma/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Return Merchandise Authorization Management
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:ff393a4ae1a4e373490a3d9129969c7a98f022e1e3b823a1d8653ed23c97ce55
!! source digest: sha256:4c6046c0f48cbcedbf0938b09da85d78cb0435ccf2327a138e572cc8d432ac2e
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

.. |badge1| image:: https://img.shields.io/badge/maturity-Production%2FStable-green.png
Expand Down Expand Up @@ -165,6 +165,7 @@ Contributors

* Chafique Delli <[email protected]>
* Giovanni Serra - Ooops <[email protected]>
* Michael Tietz (MT Software) <[email protected]>

Maintainers
~~~~~~~~~~~
Expand Down
13 changes: 12 additions & 1 deletion rma/hooks.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Copyright 2020 Tecnativa - Ernesto Tejeda
# Copyright 2023 Michael Tietz (MT Software) <[email protected]>
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from odoo import SUPERUSER_ID, api
Expand All @@ -24,7 +25,9 @@ def _get_next_picking_type_color():
def create_rma_locations(warehouse):
stock_location = env["stock.location"]
if not warehouse.rma_loc_id:
rma_location_vals = warehouse._get_rma_location_values()
rma_location_vals = warehouse._get_rma_location_values(
{"company_id": warehouse.company_id.id}, warehouse.code
)
warehouse.rma_loc_id = (
stock_location.with_context(active_test=False)
.create(rma_location_vals)
Expand Down Expand Up @@ -61,11 +64,19 @@ def create_rma_picking_types(whs):
whs.rma_in_type_id.return_picking_type_id = whs.rma_out_type_id.id
whs.rma_out_type_id.return_picking_type_id = whs.rma_in_type_id.id

def create_rma_routes(warehouses):
"""Create initially rma in/out stock.location.routes and stock.rules"""
warehouses = warehouses.with_context(rma_post_init_hook=True)
for wh in warehouses:
route_vals = wh._create_or_update_route()
wh.write(route_vals)

# Create rma locations and picking types
warehouses = env["stock.warehouse"].search([])
for warehouse in warehouses:
create_rma_locations(warehouse)
create_rma_picking_types(warehouse)
create_rma_routes(warehouses)
# Create rma sequence per company
for company in env["res.company"].search([]):
company.create_rma_index()
Loading
Loading