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][ADD] stock_orderpoint_default_location #5

Merged
merged 1 commit into from
Apr 23, 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
6 changes: 6 additions & 0 deletions setup/stock_orderpoint_default_location/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,
)
100 changes: 100 additions & 0 deletions stock_orderpoint_default_location/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
=================================
Stock Orderpoint Default Location
=================================

..
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:85eb7e71c1de0fd360e74e80a317f5de3435394369031fd5b79c10766e64edf5
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

.. |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--orderpoint-lightgray.png?logo=github
:target: https://github.com/OCA/stock-logistics-orderpoint/tree/16.0/stock_orderpoint_default_location
:alt: OCA/stock-logistics-orderpoint
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/stock-logistics-orderpoint-16-0/stock-logistics-orderpoint-16-0-stock_orderpoint_default_location
: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-orderpoint&target_branch=16.0
:alt: Try me on Runboat

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

This module allows to define a different default location than the
'Stock Location'.

**Table of contents**

.. contents::
:local:

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

In some advanced configurations, stock orderpoints could have a
different replenishment location than the warehouse 'Stock Location'.

In order to get that different replenishment location by default, a new
field should be necessary on warehouses to define that new default
value.

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

To set a different default location for new orderpoints:

#. Go to Inventory > Settings > Warehouse #. Enable 'Storage Locations'
and 'Multi-Step Routes'

#. Go to Inventory > Warehouse Management > Warehouses #. Pick the one
you want to modify #. In the 'Warehouse Configuration' tab > Default
Orderpoint Location, select the one you want as default for new
orderpoints.

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

Bugs are tracked on `GitHub Issues <https://github.com/OCA/stock-logistics-orderpoint/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-orderpoint/issues/new?body=module:%20stock_orderpoint_default_location%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
-------

* ACSONE SA/NV

Contributors
------------

- Denis Roussel denis.roussel@acsone.eu

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-orderpoint <https://github.com/OCA/stock-logistics-orderpoint/tree/16.0/stock_orderpoint_default_location>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
1 change: 1 addition & 0 deletions stock_orderpoint_default_location/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
19 changes: 19 additions & 0 deletions stock_orderpoint_default_location/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Copyright 2023 ACSONE SA/NV
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

{
"name": "Stock Orderpoint Default Location",
"summary": """
This module allows to define a different default location than the stock location""",
"version": "16.0.1.0.0",
"license": "AGPL-3",
"author": "ACSONE SA/NV,Odoo Community Association (OCA)",
"website": "https://github.com/OCA/stock-logistics-orderpoint",
"depends": [
"stock",
"base_partition",
],
"data": [
"views/stock_warehouse.xml",
],
}
2 changes: 2 additions & 0 deletions stock_orderpoint_default_location/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from . import stock_warehouse_orderpoint
from . import stock_warehouse
16 changes: 16 additions & 0 deletions stock_orderpoint_default_location/models/stock_warehouse.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Copyright 2023 ACSONE SA/NV
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from odoo import fields, models


class StockWarehouse(models.Model):

_inherit = "stock.warehouse"

default_orderpoint_location_id = fields.Many2one(
comodel_name="stock.location",
help="Choose here a stock location that will be used as default one "
"for new orderpoints. Either the default behavior will be used and "
" will choose the 'Location Stock'.",
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Copyright 2023 ACSONE SA/NV
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from odoo import models


class StockWarehouseOrderpoint(models.Model):

_inherit = "stock.warehouse.orderpoint"

def _compute_location_id(self):
"""Finds location id for changed warehouse."""
no_default_orderpoints = set()
for warehouse, orderpoints in self.partition("warehouse_id").items():
# If warehouse is not set
if not warehouse:
for company, orderpoints_company in orderpoints.partition(
"company_id"
).items():
warehouse = self.env["stock.warehouse"].search(
[
("company_id", "=", company.id),
("default_orderpoint_location_id", "!=", False),
],
limit=1,
)
default_location = warehouse.default_orderpoint_location_id
if default_location:
orderpoints_company.update({"location_id": default_location.id})
else:
no_default_orderpoints.update(orderpoints_company._ids)
else:
default_location = warehouse.default_orderpoint_location_id
if default_location:
orderpoints.update({"location_id": default_location.id})
else:
no_default_orderpoints.update(orderpoints._ids)
return super(
StockWarehouseOrderpoint, self.browse(no_default_orderpoints)
)._compute_location_id()
8 changes: 8 additions & 0 deletions stock_orderpoint_default_location/readme/CONFIGURE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
To set a different default location for new orderpoints:

#. Go to Inventory > Settings > Warehouse #. Enable 'Storage Locations' and 'Multi-Step
Routes'

#. Go to Inventory > Warehouse Management > Warehouses #. Pick the one you want to
modify #. In the 'Warehouse Configuration' tab > Default Orderpoint Location, select the
one you want as default for new orderpoints.
5 changes: 5 additions & 0 deletions stock_orderpoint_default_location/readme/CONTEXT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
In some advanced configurations, stock orderpoints could have a different replenishment
location than the warehouse 'Stock Location'.

In order to get that different replenishment location by default, a new field should be
necessary on warehouses to define that new default value.
1 change: 1 addition & 0 deletions stock_orderpoint_default_location/readme/CONTRIBUTORS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- Denis Roussel <denis.roussel@acsone.eu>
1 change: 1 addition & 0 deletions stock_orderpoint_default_location/readme/DESCRIPTION.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
This module allows to define a different default location than the 'Stock Location'.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Loading