Skip to content

Commit

Permalink
[16.0][ADD] stock_quant_package_fast_move
Browse files Browse the repository at this point in the history
  • Loading branch information
angelinaanaki committed Feb 26, 2024
1 parent 5379b81 commit 888da7c
Show file tree
Hide file tree
Showing 28 changed files with 1,363 additions and 0 deletions.
6 changes: 6 additions & 0 deletions setup/stock_quant_package_fast_move/setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import setuptools

setuptools.setup(
setup_requires=['setuptools-odoo'],
odoo_addon=True,
)
134 changes: 134 additions & 0 deletions stock_quant_package_fast_move/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
===================================
Fast Package Move Between Locations
===================================

..
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:53129da11b93c9b036f2a132594fc1be4de37f42f675ed6e844c0ad3136f7565
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
:target: https://odoo-community.org/page/development-status
:alt: Beta
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fstock--logistics--workflow-lightgray.png?logo=github
:target: https://github.com/OCA/stock-logistics-workflow/tree/16.0/stock_quant_package_fast_move
:alt: OCA/stock-logistics-workflow
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/stock-logistics-workflow-16-0/stock-logistics-workflow-16-0-stock_quant_package_fast_move
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
:target: https://runboat.odoo-community.org/builds?repo=OCA/stock-logistics-workflow&target_branch=16.0
:alt: Try me on Runboat

|badge1| |badge2| |badge3| |badge4| |badge5|

This module simplifies package movement between different warehouse locations.

You can simply select several packages and use a wizard that will perform all the underlying inventory operations.

NB: this module depends on the [Stock Picking Move Package to Another Package](https://github.com/OCA/stock-logistics-workflow/stock_picking_move_package_to_package) module.
You should configure it properly in case you want to use the 'destination package' option.

**Table of contents**

.. contents::
:local:

Use Cases / Context
===================

Imagine that you need to transfer different packages between different locations in your warehouse.

Regular Odoo flow looks like this:

- Go to the "Inventory -> Overview" and select an operation type (eg 'Internal Transfer')
- Create a corresponding picking
- Add packages if 'Move Entire Packages' is enabled or add all the package products
- Set quantities done
- Validate


However if you are working with packages you will primary operate from the "Packages" menu.

And it would be much convenient if you could move packages directly from this menu.

This is what this module is designed for.

Configuration
=============

- Go to the "Inventory -> Configuration -> Settings"
- Activate the "Packages" checkbox
- In the "Package Move Operation" select the operation type that will be used for the easy package transfers. This setting is configured for each company separately

.. image:: https://raw.githubusercontent.com/OCA/stock-logistics-workflow/16.0/stock_quant_package_fast_move/static/img/package_fast_move_configure.png

Usage
=====

- Go to the "Inventory -> Products -> Packages"

- Open a package or select several packages in the list vies. Important: all selected packages must be located in the same location

- Open the "Action" menu and select "Move packages"

- In the opened wizard select the destination location where you want to move the packages

- You can select an optional destination package in the "Destination Package" field. If selected the content of the selected packages will be moved into the destination package located at the destination location.

- If you check 'Validate', the created internal picking will be validated. Otherwise it will remain in the "Ready" state.

- Click the "Move" button

.. image:: https://raw.githubusercontent.com/OCA/stock-logistics-workflow/16.0/stock_quant_package_fast_move/static/img/package_fast_move_action.png

Known issues / Roadmap
======================

Only packages residing in the same source location can be moved.

Bug Tracker
===========

Bugs are tracked on `GitHub Issues <https://github.com/OCA/stock-logistics-workflow/issues>`_.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us to smash it by providing a detailed and welcomed
`feedback <https://github.com/OCA/stock-logistics-workflow/issues/new?body=module:%20stock_quant_package_fast_move%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.

Do not contact contributors directly about support or help with technical issues.

Credits
=======

Authors
~~~~~~~

* Cetmix

Contributors
~~~~~~~~~~~~

* Cetmix <https://cetmix.com/>

Maintainers
~~~~~~~~~~~

This module is maintained by the OCA.

.. image:: https://odoo-community.org/logo.png
:alt: Odoo Community Association
:target: https://odoo-community.org

OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.

This module is part of the `OCA/stock-logistics-workflow <https://github.com/OCA/stock-logistics-workflow/tree/16.0/stock_quant_package_fast_move>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
5 changes: 5 additions & 0 deletions stock_quant_package_fast_move/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Copyright (C) 2023 Cetmix OÜ
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from . import models
from . import wizard
18 changes: 18 additions & 0 deletions stock_quant_package_fast_move/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Copyright (C) 2023 Cetmix OÜ
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
{
"name": "Fast Package Move Between Locations",
"version": "16.0.1.0.0",
"category": "Inventory/Inventory",
"summary": "Move packages between locations directly from the 'Package' menu",
"depends": ["stock_picking_move_package_to_package"],
"website": "https://github.com/OCA/stock-logistics-workflow",
"author": "Cetmix, Odoo Community Association (OCA)",
"installable": True,
"data": [
"security/ir.model.access.csv",
"wizard/stock_quant_package_fast_move_wizard.xml",
"views/res_config_settings_view.xml",
],
"license": "AGPL-3",
}
6 changes: 6 additions & 0 deletions stock_quant_package_fast_move/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Copyright (C) 2023 Cetmix OÜ
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from . import stock_quant_package
from . import res_company
from . import res_config_settings
12 changes: 12 additions & 0 deletions stock_quant_package_fast_move/models/res_company.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Copyright (C) 2023 Cetmix OÜ
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from odoo import fields, models


class ResCompany(models.Model):
_inherit = "res.company"

package_move_picking_type_id = fields.Many2one(
"stock.picking.type", string="Package Move Operation"
)
12 changes: 12 additions & 0 deletions stock_quant_package_fast_move/models/res_config_settings.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Copyright (C) 2023 Cetmix OÜ
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from odoo import fields, models


class ResConfigSettings(models.TransientModel):
_inherit = "res.config.settings"

package_move_picking_type_id = fields.Many2one(
related="company_id.package_move_picking_type_id", readonly=False
)
110 changes: 110 additions & 0 deletions stock_quant_package_fast_move/models/stock_quant_package.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
# Copyright (C) 2023 Cetmix OÜ
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from odoo import _, exceptions, models


class StockQuantPackage(models.Model):
_inherit = "stock.quant.package"

def action_show_package_fast_move_wizard(self):
"""Open wizard for fast package movement."""
return {

Check warning on line 12 in stock_quant_package_fast_move/models/stock_quant_package.py

View check run for this annotation

Codecov / codecov/patch

stock_quant_package_fast_move/models/stock_quant_package.py#L12

Added line #L12 was not covered by tests
"type": "ir.actions.act_window",
"name": _("Move Packages"),
"res_model": "stock.quant.package.fast.move.wizard",
"target": "new",
"view_id": self.env.ref(
"stock_quant_package_fast_move.stock_quant_package_fast_move_wizard_view_form"
).id,
"view_mode": "form",
"context": self.env.context,
}

def check_source_location(self):
if any(package.location_id != self[0].location_id for package in self):
raise exceptions.UserError(

Check warning on line 26 in stock_quant_package_fast_move/models/stock_quant_package.py

View check run for this annotation

Codecov / codecov/patch

stock_quant_package_fast_move/models/stock_quant_package.py#L26

Added line #L26 was not covered by tests
_("All packages must have the same source location.")
)

def _move_to_location(self, location, destination_package=None, validate=False):
"""
Move packages to a specified location.
Parameters:
- location (recordset of stock.location): The destination location.
- destination_package (recordset of stock.quant.package, optional):
Optional destination package. If provided, it must belong to the specified location.
- validate (boolean, optional):
If set to True, the created picking will be validated.
Otherwise it will remain in the "Ready" state. Defaults to False.
Returns:
- bool: True if the move is successful.
Raises:
- exceptions.UserError: If the source location of the packages is different,
If the destination location is the same as the current location
or if the destination package does not belong to the specified location.
"""
self.check_source_location()

# Check if the location is different from the current location
if location == self[0].location_id and not destination_package:
raise exceptions.UserError(
_("The destination location is the same as the current location.")
)

# Check if the destination package belongs to the same location
# If the location_id is False it means that the package is new or empty
if (
destination_package
and destination_package.location_id
and destination_package.location_id != location
):
raise exceptions.UserError(
_("The destination package does not belong to the specified location.")
)

active_company = self.env.company
picking_type_id = active_company.package_move_picking_type_id

# Create a picking
picking_vals = {
"location_id": self[0].location_id.id,
"location_dest_id": location.id,
"picking_type_id": picking_type_id.id,
}
picking = self.env["stock.picking"].create(picking_vals)

for package in self:
# Create a package_level record for each package
package_level_vals = {
"package_id": package.id,
"package_dest_id": destination_package.id
if destination_package
else False,
"picking_id": picking.id,
"company_id": active_company.id,
"location_id": package.location_id.id,
"location_dest_id": location.id,
}
package_level = self.env["stock.package_level"].create(package_level_vals)
package_level.write({"is_done": True})

picking.action_confirm()
if validate:
# Validate the picking
picking.button_validate()

return True

def create_new_package(self):
"""
Create a new stock package.
Returns:
- package (recordset of stock.quant.package): The newly created package object.
"""
package = self.env["stock.quant.package"].create({})
return package

Check warning on line 110 in stock_quant_package_fast_move/models/stock_quant_package.py

View check run for this annotation

Codecov / codecov/patch

stock_quant_package_fast_move/models/stock_quant_package.py#L109-L110

Added lines #L109 - L110 were not covered by tests
5 changes: 5 additions & 0 deletions stock_quant_package_fast_move/readme/CONFIGURE.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
- Go to the "Inventory -> Configuration -> Settings"
- Activate the "Packages" checkbox
- In the "Package Move Operation" select the operation type that will be used for the easy package transfers. This setting is configured for each company separately

.. image:: ../static/img/package_fast_move_configure.png
16 changes: 16 additions & 0 deletions stock_quant_package_fast_move/readme/CONTEXT.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
Imagine that you need to transfer different packages between different locations in your warehouse.

Regular Odoo flow looks like this:

- Go to the "Inventory -> Overview" and select an operation type (eg 'Internal Transfer')
- Create a corresponding picking
- Add packages if 'Move Entire Packages' is enabled or add all the package products
- Set quantities done
- Validate


However if you are working with packages you will primary operate from the "Packages" menu.

And it would be much convenient if you could move packages directly from this menu.

This is what this module is designed for.
1 change: 1 addition & 0 deletions stock_quant_package_fast_move/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* Cetmix <https://cetmix.com/>
6 changes: 6 additions & 0 deletions stock_quant_package_fast_move/readme/DESCRIPTION.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
This module simplifies package movement between different warehouse locations.

You can simply select several packages and use a wizard that will perform all the underlying inventory operations.

NB: this module depends on the [Stock Picking Move Package to Another Package](https://github.com/OCA/stock-logistics-workflow/stock_picking_move_package_to_package) module.
You should configure it properly in case you want to use the 'destination package' option.
1 change: 1 addition & 0 deletions stock_quant_package_fast_move/readme/ROADMAP.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Only packages residing in the same source location can be moved.
15 changes: 15 additions & 0 deletions stock_quant_package_fast_move/readme/USAGE.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
- Go to the "Inventory -> Products -> Packages"

- Open a package or select several packages in the list vies. Important: all selected packages must be located in the same location

- Open the "Action" menu and select "Move packages"

- In the opened wizard select the destination location where you want to move the packages

- You can select an optional destination package in the "Destination Package" field. If selected the content of the selected packages will be moved into the destination package located at the destination location.

- If you check 'Validate', the created internal picking will be validated. Otherwise it will remain in the "Ready" state.

- Click the "Move" button

.. image:: ../static/img/package_fast_move_action.png
2 changes: 2 additions & 0 deletions stock_quant_package_fast_move/security/ir.model.access.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
stock_quant_package_fast_move.access_stock_quant_package_fast_move_wizard,access_stock_quant_package_fast_move_wizard,stock_quant_package_fast_move.model_stock_quant_package_fast_move_wizard,stock.group_stock_user,1,1,1,1
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 888da7c

Please sign in to comment.