mirror of
https://github.com/OCA/stock-logistics-warehouse.git
synced 2025-01-21 14:27:28 +02:00
[ADD] stock_picking_procure_method: New module
This commit is contained in:
142
stock_picking_procure_method/README.rst
Normal file
142
stock_picking_procure_method/README.rst
Normal file
@@ -0,0 +1,142 @@
|
||||
============================
|
||||
Stock Picking Procure Method
|
||||
============================
|
||||
|
||||
.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||
!! This file is generated by oca-gen-addon-readme !!
|
||||
!! changes will be overwritten. !!
|
||||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||
|
||||
.. |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--warehouse-lightgray.png?logo=github
|
||||
:target: https://github.com/OCA/stock-logistics-warehouse/tree/12.0/stock_picking_procure_method
|
||||
:alt: OCA/stock-logistics-warehouse
|
||||
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
|
||||
:target: https://translation.odoo-community.org/projects/stock-logistics-warehouse-12-0/stock-logistics-warehouse-12-0-stock_picking_procure_method
|
||||
:alt: Translate me on Weblate
|
||||
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png
|
||||
:target: https://runbot.odoo-community.org/runbot/153/12.0
|
||||
:alt: Try me on Runbot
|
||||
|
||||
|badge1| |badge2| |badge3| |badge4| |badge5|
|
||||
|
||||
This module adds the possibility to set the supply method to *Apply Procurement
|
||||
Rules* in the pickings, which is normally set to *Take From Stock* by default.
|
||||
|
||||
This way, you can configure MTO flows triggered from the picking itself.
|
||||
|
||||
**Table of contents**
|
||||
|
||||
.. contents::
|
||||
:local:
|
||||
|
||||
Installation
|
||||
============
|
||||
|
||||
This module is useless without either Odoo's `mrp` or `purchase` modules (or
|
||||
both). Depending on your needs you should install them in advance.
|
||||
|
||||
Configuration
|
||||
=============
|
||||
|
||||
This is an example scenario with two warehouses. WH2 will be allways supplied
|
||||
through WH1.
|
||||
|
||||
Common steps to `mrp` and `purchase` procurements:
|
||||
|
||||
#. Go to *Inventory > Configuration > Settings > Warehouse* and set *Multi-Step
|
||||
Routes* on.
|
||||
#. Go to *Inventory > Configuration > Warehouse Management > Warehouses*
|
||||
#. Create **WH1** with either *Manufacture in this Warehouse* or *Purchase to
|
||||
resupply this warehouse* or both set.
|
||||
#. Create **WH2** setting off *Manufacture in this Warehouse* and *Purchase to
|
||||
resupply this warehouse*. Set **WH1** as the *Resupply Warehouse*.
|
||||
#. Go to *Inventory > Configuration > Warehouse Management > Routes* and click
|
||||
on the *Make To Order* one.
|
||||
#. Add a new *Procurement Rule* with these settings and save:
|
||||
|
||||
- Name: *WH1 -> WH2-MTO*
|
||||
- Action: *Move From Another Location*
|
||||
- Procurement Location: *WH2/Stock*
|
||||
- Served Warehouse: *WH2*
|
||||
- Source Location: *WH1/Stock*
|
||||
- Move Supply Method: *Create Procurement*
|
||||
- Operation Type: *WH1: Internal Transfers*
|
||||
- Propagation of Procurement Group: *Propagate*
|
||||
- Propagate cancel and split: `True`
|
||||
- Warehouse to Propagate: *WH1*
|
||||
|
||||
Now if you want to trigger a manufacture:
|
||||
|
||||
- Create a stockable product product with a BoM list.
|
||||
- In the product's *Inventory > Routes section* set *Make To Order* and
|
||||
*Manufacture* on.
|
||||
|
||||
Or if you want to trigger a purchase:
|
||||
|
||||
- Create a stockable product product with a supplier.
|
||||
- In the product's *Inventory > Routes section* set *Make To Order* and
|
||||
*Purchase* on.
|
||||
|
||||
Usage
|
||||
=====
|
||||
|
||||
After configuring you procurement rules and your product routes:
|
||||
|
||||
#. Go to *Inventory > Dashboard* and click on the *more options* icon (☰).
|
||||
#. Choose *New > Planned Transfer*.
|
||||
#. Set an origin and destination that is considered in the routes procurement
|
||||
rules.
|
||||
#. Set *Supply Method* to *Apply Procurement Rules*.
|
||||
#. Set the products and quantities you want to supply.
|
||||
#. Save and click on *Mark as To Do*.
|
||||
#. Depending on the product's supply type a new MO or a new PO should be
|
||||
created.
|
||||
|
||||
Bug Tracker
|
||||
===========
|
||||
|
||||
Bugs are tracked on `GitHub Issues <https://github.com/OCA/stock-logistics-warehouse/issues>`_.
|
||||
In case of trouble, please check there if your issue has already been reported.
|
||||
If you spotted it first, help us smashing it by providing a detailed and welcomed
|
||||
`feedback <https://github.com/OCA/stock-logistics-warehouse/issues/new?body=module:%20stock_picking_procure_method%0Aversion:%2012.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
|
||||
~~~~~~~
|
||||
|
||||
* Tecnativa
|
||||
|
||||
Contributors
|
||||
~~~~~~~~~~~~
|
||||
|
||||
* `Tecnativa <https://www.tecnativa.com>`_:
|
||||
|
||||
* David Vidal
|
||||
* Pedro M. Baeza
|
||||
|
||||
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-warehouse <https://github.com/OCA/stock-logistics-warehouse/tree/12.0/stock_picking_procure_method>`_ project on GitHub.
|
||||
|
||||
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
|
||||
1
stock_picking_procure_method/__init__.py
Normal file
1
stock_picking_procure_method/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
from . import models
|
||||
19
stock_picking_procure_method/__manifest__.py
Normal file
19
stock_picking_procure_method/__manifest__.py
Normal file
@@ -0,0 +1,19 @@
|
||||
# Copyright 2018 Tecnativa - David Vidal
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
||||
{
|
||||
'name': 'Stock Picking Procure Method',
|
||||
'summary': 'Allows to force the procurement method from the picking',
|
||||
'version': '11.0.1.0.0',
|
||||
'category': 'Warehouse',
|
||||
'author': 'Tecnativa,'
|
||||
'Odoo Community Association (OCA)',
|
||||
'website': 'https://github.com/OCA/stock-logistics-warehouse',
|
||||
'license': 'AGPL-3',
|
||||
'depends': [
|
||||
'stock',
|
||||
],
|
||||
'data': [
|
||||
'views/stock_picking_views.xml',
|
||||
],
|
||||
'installable': True,
|
||||
}
|
||||
1
stock_picking_procure_method/models/__init__.py
Normal file
1
stock_picking_procure_method/models/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
from . import stock_picking
|
||||
43
stock_picking_procure_method/models/stock_picking.py
Normal file
43
stock_picking_procure_method/models/stock_picking.py
Normal file
@@ -0,0 +1,43 @@
|
||||
# Copyright 2018 Tecnativa - David Vidal
|
||||
# Copyright 2018 Tecnativa - Pedro M. Baeza
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
||||
|
||||
from odoo import api, fields, models
|
||||
|
||||
|
||||
class StockPicking(models.Model):
|
||||
_inherit = 'stock.picking'
|
||||
|
||||
procure_method = fields.Selection(
|
||||
selection='_selection_procure_method',
|
||||
compute='_compute_procure_method',
|
||||
inverse='_inverse_procure_method',
|
||||
string='Supply Method',
|
||||
help='By default, the system will take from the stock in the source '
|
||||
'location and passively wait for availability. The other '
|
||||
'possibility allows you to directly create a procurement on the '
|
||||
'source location (and thus ignore its current stock) to gather '
|
||||
'products. If we want to chain moves and have this one to wait '
|
||||
'for the previous, this second option should be chosen.',
|
||||
)
|
||||
|
||||
def _selection_procure_method(self):
|
||||
return self.env['stock.move'].fields_get(
|
||||
allfields=['procure_method'])['procure_method']['selection']
|
||||
|
||||
@api.depends('move_lines.procure_method')
|
||||
def _compute_procure_method(self):
|
||||
for picking in self:
|
||||
procure_method = False
|
||||
for move in picking.move_lines:
|
||||
if not procure_method:
|
||||
procure_method = move.procure_method
|
||||
elif procure_method != move.procure_method:
|
||||
procure_method = False
|
||||
break
|
||||
picking.procure_method = procure_method
|
||||
|
||||
def _inverse_procure_method(self):
|
||||
self.filtered('procure_method').mapped('move_lines').update({
|
||||
'procure_method': self.procure_method,
|
||||
})
|
||||
38
stock_picking_procure_method/readme/CONFIGURE.rst
Normal file
38
stock_picking_procure_method/readme/CONFIGURE.rst
Normal file
@@ -0,0 +1,38 @@
|
||||
This is an example scenario with two warehouses. WH2 will be allways supplied
|
||||
through WH1.
|
||||
|
||||
Common steps to `mrp` and `purchase` procurements:
|
||||
|
||||
#. Go to *Inventory > Configuration > Settings > Warehouse* and set *Multi-Step
|
||||
Routes* on.
|
||||
#. Go to *Inventory > Configuration > Warehouse Management > Warehouses*
|
||||
#. Create **WH1** with either *Manufacture in this Warehouse* or *Purchase to
|
||||
resupply this warehouse* or both set.
|
||||
#. Create **WH2** setting off *Manufacture in this Warehouse* and *Purchase to
|
||||
resupply this warehouse*. Set **WH1** as the *Resupply Warehouse*.
|
||||
#. Go to *Inventory > Configuration > Warehouse Management > Routes* and click
|
||||
on the *Make To Order* one.
|
||||
#. Add a new *Procurement Rule* with these settings and save:
|
||||
|
||||
- Name: *WH1 -> WH2-MTO*
|
||||
- Action: *Move From Another Location*
|
||||
- Procurement Location: *WH2/Stock*
|
||||
- Served Warehouse: *WH2*
|
||||
- Source Location: *WH1/Stock*
|
||||
- Move Supply Method: *Create Procurement*
|
||||
- Operation Type: *WH1: Internal Transfers*
|
||||
- Propagation of Procurement Group: *Propagate*
|
||||
- Propagate cancel and split: `True`
|
||||
- Warehouse to Propagate: *WH1*
|
||||
|
||||
Now if you want to trigger a manufacture:
|
||||
|
||||
- Create a stockable product product with a BoM list.
|
||||
- In the product's *Inventory > Routes section* set *Make To Order* and
|
||||
*Manufacture* on.
|
||||
|
||||
Or if you want to trigger a purchase:
|
||||
|
||||
- Create a stockable product product with a supplier.
|
||||
- In the product's *Inventory > Routes section* set *Make To Order* and
|
||||
*Purchase* on.
|
||||
4
stock_picking_procure_method/readme/CONTRIBUTORS.rst
Normal file
4
stock_picking_procure_method/readme/CONTRIBUTORS.rst
Normal file
@@ -0,0 +1,4 @@
|
||||
* `Tecnativa <https://www.tecnativa.com>`_:
|
||||
|
||||
* David Vidal
|
||||
* Pedro M. Baeza
|
||||
4
stock_picking_procure_method/readme/DESCRIPTION.rst
Normal file
4
stock_picking_procure_method/readme/DESCRIPTION.rst
Normal file
@@ -0,0 +1,4 @@
|
||||
This module adds the possibility to set the supply method to *Apply Procurement
|
||||
Rules* in the pickings, which is normally set to *Take From Stock* by default.
|
||||
|
||||
This way, you can configure MTO flows triggered from the picking itself.
|
||||
2
stock_picking_procure_method/readme/INSTALL.rst
Normal file
2
stock_picking_procure_method/readme/INSTALL.rst
Normal file
@@ -0,0 +1,2 @@
|
||||
This module is useless without either Odoo's `mrp` or `purchase` modules (or
|
||||
both). Depending on your needs you should install them in advance.
|
||||
11
stock_picking_procure_method/readme/USAGE.rst
Normal file
11
stock_picking_procure_method/readme/USAGE.rst
Normal file
@@ -0,0 +1,11 @@
|
||||
After configuring you procurement rules and your product routes:
|
||||
|
||||
#. Go to *Inventory > Dashboard* and click on the *more options* icon (☰).
|
||||
#. Choose *New > Planned Transfer*.
|
||||
#. Set an origin and destination that is considered in the routes procurement
|
||||
rules.
|
||||
#. Set *Supply Method* to *Apply Procurement Rules*.
|
||||
#. Set the products and quantities you want to supply.
|
||||
#. Save and click on *Mark as To Do*.
|
||||
#. Depending on the product's supply type a new MO or a new PO should be
|
||||
created.
|
||||
1
stock_picking_procure_method/tests/__init__.py
Normal file
1
stock_picking_procure_method/tests/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
from . import test_stock_picking_procure_method
|
||||
@@ -0,0 +1,74 @@
|
||||
# Copyright 2018 Tecnativa - David Vidal
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
||||
|
||||
from odoo.tests import common
|
||||
|
||||
|
||||
class TestStockPickingMTO(common.SavepointCase):
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
super(TestStockPickingMTO, cls).setUpClass()
|
||||
cls.mto_route = cls.env.ref('stock.route_warehouse0_mto')
|
||||
cls.product = cls.env['product.product'].create({
|
||||
'name': 'Test MTO Product',
|
||||
'route_ids': [
|
||||
(6, 0, cls.mto_route.ids)],
|
||||
'type': 'product',
|
||||
})
|
||||
cls.wh_obj = cls.env['stock.warehouse']
|
||||
cls.wh1 = cls.wh_obj.create({
|
||||
'name': 'Test WH1',
|
||||
'code': 'TSWH1',
|
||||
})
|
||||
cls.wh2 = cls.wh_obj.create({
|
||||
'name': 'Test WH2',
|
||||
'code': 'TSWH2',
|
||||
'resupply_wh_ids': [(6, 0, cls.wh1.ids)],
|
||||
})
|
||||
cls.procurement_rule = cls.env['procurement.rule'].create({
|
||||
'name': 'TST-WH1 -> TST-WH2 MTO',
|
||||
'route_id': cls.mto_route.id,
|
||||
'action': 'move',
|
||||
'location_src_id': cls.wh1.lot_stock_id.id,
|
||||
'procure_method': 'make_to_stock',
|
||||
'picking_type_id': cls.wh1.int_type_id.id,
|
||||
'location_id': cls.wh2.lot_stock_id.id,
|
||||
'warehouse_id': cls.wh2.id,
|
||||
'group_propagation_option': 'propagate',
|
||||
'propagate': True,
|
||||
'propagate_warehouse_id': cls.wh1.id,
|
||||
})
|
||||
cls.picking_obj = cls.env['stock.picking'].with_context(
|
||||
planned_picking=True)
|
||||
cls.picking = cls.picking_obj.create({
|
||||
'picking_type_id': cls.wh1.int_type_id.id,
|
||||
'location_id': cls.wh1.lot_stock_id.id,
|
||||
'location_dest_id': cls.wh2.lot_stock_id.id,
|
||||
})
|
||||
|
||||
def test_compute_procure_method(self):
|
||||
# No moves
|
||||
self.assertFalse(self.picking.procure_method)
|
||||
# A new move defaults to MTS
|
||||
move_line = self.env['stock.move'].create({
|
||||
'name': 'TSTMOVE001',
|
||||
'picking_id': self.picking.id,
|
||||
'product_id': self.product.id,
|
||||
'product_uom': self.product.uom_id.id,
|
||||
'product_uom_qty': 100,
|
||||
'location_id': self.wh1.lot_stock_id.id,
|
||||
'location_dest_id': self.wh2.lot_stock_id.id,
|
||||
})
|
||||
self.assertEqual(self.picking.procure_method, 'make_to_stock')
|
||||
# Change move procure method to MTO
|
||||
move_line.procure_method = 'make_to_order'
|
||||
self.assertEqual(self.picking.procure_method, 'make_to_order')
|
||||
# Add a new line with MTS rule
|
||||
move_line.copy({
|
||||
'procure_method': 'make_to_stock',
|
||||
})
|
||||
self.assertFalse(self.picking.procure_method)
|
||||
# We set the procure method in the picking
|
||||
self.picking.procure_method = 'make_to_order'
|
||||
self.assertEqual(self.picking.move_lines[1].procure_method,
|
||||
'make_to_order')
|
||||
16
stock_picking_procure_method/views/stock_picking_views.xml
Normal file
16
stock_picking_procure_method/views/stock_picking_views.xml
Normal file
@@ -0,0 +1,16 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<odoo>
|
||||
|
||||
<record model="ir.ui.view" id="stock_picking_form_view">
|
||||
<field name="model">stock.picking</field>
|
||||
<field name="inherit_id" ref="stock.view_picking_form"/>
|
||||
<field name="arch" type="xml">
|
||||
<field name="scheduled_date" position="after">
|
||||
<field name="procure_method"
|
||||
attrs="{'readonly': [('state', '!=', 'draft')], 'invisible': [('state', '!=', 'draft')]}"
|
||||
groups="stock.group_adv_location"/>
|
||||
</field>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
</odoo>
|
||||
Reference in New Issue
Block a user