mirror of
https://github.com/OCA/stock-logistics-warehouse.git
synced 2025-01-21 14:27:28 +02:00
[10.0][MIG] stock_available & stock_available_immediately (#219)
This commit is contained in:
@@ -1,3 +1,8 @@
|
||||
.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg
|
||||
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
|
||||
:alt: License: AGPL-3
|
||||
|
||||
==========================
|
||||
Stock available to promise
|
||||
==========================
|
||||
|
||||
@@ -8,16 +13,16 @@ configuration, it can account for various data such as sales quotations or
|
||||
immediate production capacity.
|
||||
In case of immediate production capacity, it is possible to configure on which
|
||||
field the potential is computed, by default Quantity On Hand is used.
|
||||
This can be configured in the menu Settings > Configuration > Warehouse.
|
||||
This can be configured in `Inventory` > `Configuration` > `Settings`.
|
||||
|
||||
Configuration
|
||||
=============
|
||||
|
||||
By default, this module computes the stock available to promise as the virtual
|
||||
stock.
|
||||
To take davantage of the additional features, you must which information you
|
||||
To take advantage of the additional features, you must which information you
|
||||
want to base the computation, by checking one or more boxes in the settings:
|
||||
`Configuration` > `Warehouse` > `Stock available to promise`.
|
||||
`Inventory` > `Configuration` > `Settings` > `Stock available to promise`.
|
||||
In case of "Include the production potential", it is also possible to configure
|
||||
which field of product to use to compute the production potential.
|
||||
|
||||
@@ -28,25 +33,43 @@ This module adds a field named `Available for sale` on the Product form.
|
||||
Various additional fields may be added, depending on which information you
|
||||
chose to base the computation on.
|
||||
|
||||
.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas
|
||||
:alt: Try me on Runbot
|
||||
:target: https://runbot.odoo-community.org/runbot/153/10.0
|
||||
|
||||
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.
|
||||
|
||||
Credits
|
||||
=======
|
||||
|
||||
Images
|
||||
------
|
||||
|
||||
* Odoo Community Association: `Icon <https://github.com/OCA/maintainer-tools/blob/master/template/module/static/description/icon.svg>`_.
|
||||
|
||||
Contributors
|
||||
------------
|
||||
|
||||
* Lionel Sausin (Numérigraphe) <ls@numerigraphe.com>
|
||||
* Sodexis <sodexis@sodexis.com>
|
||||
* many others contributed to sub-modules, please refer to each sub-module's credits
|
||||
|
||||
Maintainer
|
||||
----------
|
||||
|
||||
.. image:: http://odoo-community.org/logo.png
|
||||
.. image:: https://odoo-community.org/logo.png
|
||||
:alt: Odoo Community Association
|
||||
:target: http://odoo-community.org
|
||||
:target: https://odoo-community.org
|
||||
|
||||
This module is maintained by the OCA.
|
||||
|
||||
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.
|
||||
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.
|
||||
|
||||
To contribute to this module, please visit http://odoo-community.org.
|
||||
To contribute to this module, please visit https://odoo-community.org.
|
||||
@@ -1,5 +1,6 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# © 2014 Numérigraphe, Sodexis
|
||||
# Copyright 2014 Numérigraphe
|
||||
# Copyright 2016 Sodexis
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
||||
|
||||
from . import models
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# © 2014 Numérigraphe, Sodexis
|
||||
# Copyright 2014 Numérigraphe
|
||||
# Copyright 2016 Sodexis
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
||||
|
||||
{
|
||||
'name': 'Stock available to promise',
|
||||
'version': '9.0.1.1.0',
|
||||
'version': '10.0.1.0.0',
|
||||
"author": "Numérigraphe, Sodexis, Odoo Community Association (OCA)",
|
||||
'category': 'Warehouse',
|
||||
'depends': ['stock'],
|
||||
@@ -1,5 +1,8 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# © 2014 Numérigraphe, Sodexis
|
||||
# Copyright 2014 Numérigraphe
|
||||
# Copyright 2016 Sodexis
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
||||
|
||||
from . import product_template, product_product, res_config
|
||||
from . import product_template
|
||||
from . import product_product
|
||||
from . import res_config
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# © 2014 Numérigraphe, Sodexis
|
||||
# Copyright 2014 Numérigraphe
|
||||
# Copyright 2016 Sodexis
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
||||
|
||||
from openerp import models, fields, api
|
||||
from openerp.addons import decimal_precision as dp
|
||||
from odoo import models, fields, api
|
||||
from odoo.addons import decimal_precision as dp
|
||||
|
||||
|
||||
class ProductProduct(models.Model):
|
||||
@@ -16,7 +17,7 @@ class ProductProduct(models.Model):
|
||||
|
||||
@api.multi
|
||||
@api.depends('virtual_available')
|
||||
def _immediately_usable_qty(self):
|
||||
def _compute_immediately_usable_qty(self):
|
||||
"""No-op implementation of the stock available to promise.
|
||||
|
||||
By default, available to promise = forecasted quantity.
|
||||
@@ -29,11 +30,26 @@ class ProductProduct(models.Model):
|
||||
for prod in self:
|
||||
prod.immediately_usable_qty = prod.virtual_available
|
||||
|
||||
@api.multi
|
||||
@api.depends()
|
||||
def _compute_potential_qty(self):
|
||||
"""Set potential qty to 0.0 to define the field defintion used by
|
||||
other modules to inherit it
|
||||
"""
|
||||
for product in self:
|
||||
product.potential_qty = 0.0
|
||||
|
||||
immediately_usable_qty = fields.Float(
|
||||
digits=dp.get_precision('Product Unit of Measure'),
|
||||
compute='_immediately_usable_qty',
|
||||
compute='_compute_immediately_usable_qty',
|
||||
string='Available to promise',
|
||||
help="Stock for this Product that can be safely proposed "
|
||||
"for sale to Customers.\n"
|
||||
"The definition of this value can be configured to suit "
|
||||
"your needs")
|
||||
potential_qty = fields.Float(
|
||||
compute='_compute_potential_qty',
|
||||
digits=dp.get_precision('Product Unit of Measure'),
|
||||
string='Potential',
|
||||
help="Quantity of this Product that could be produced using "
|
||||
"the materials already at hand.")
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# © 2014 Numérigraphe, Sodexis
|
||||
# Copyright 2014 Numérigraphe
|
||||
# Copyright 2016 Sodexis
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
||||
|
||||
from openerp import models, fields, api
|
||||
from openerp.addons import decimal_precision as dp
|
||||
from odoo import models, fields, api
|
||||
from odoo.addons import decimal_precision as dp
|
||||
|
||||
|
||||
class ProductTemplate(models.Model):
|
||||
@@ -11,7 +12,7 @@ class ProductTemplate(models.Model):
|
||||
|
||||
@api.multi
|
||||
@api.depends('product_variant_ids.immediately_usable_qty')
|
||||
def _immediately_usable_qty(self):
|
||||
def _compute_immediately_usable_qty(self):
|
||||
"""No-op implementation of the stock available to promise.
|
||||
|
||||
By default, available to promise = forecasted quantity.
|
||||
@@ -24,11 +25,35 @@ class ProductTemplate(models.Model):
|
||||
for tmpl in self:
|
||||
tmpl.immediately_usable_qty = tmpl.virtual_available
|
||||
|
||||
@api.multi
|
||||
@api.depends('product_variant_ids.potential_qty')
|
||||
def _compute_potential_qty(self):
|
||||
"""Compute the potential as the max of all the variants's potential.
|
||||
|
||||
We can't add the potential of variants: if they share components we
|
||||
may not be able to make all the variants.
|
||||
So we set the arbitrary rule that we can promise up to the biggest
|
||||
variant's potential.
|
||||
"""
|
||||
for tmpl in self:
|
||||
if not tmpl.product_variant_ids:
|
||||
continue
|
||||
tmpl.potential_qty = max(
|
||||
[v.potential_qty for v in tmpl.product_variant_ids])
|
||||
|
||||
immediately_usable_qty = fields.Float(
|
||||
digits=dp.get_precision('Product Unit of Measure'),
|
||||
compute='_immediately_usable_qty',
|
||||
compute='_compute_immediately_usable_qty',
|
||||
string='Available to promise',
|
||||
help="Stock for this Product that can be safely proposed "
|
||||
"for sale to Customers.\n"
|
||||
"The definition of this value can be configured to suit "
|
||||
"your needs")
|
||||
potential_qty = fields.Float(
|
||||
compute='_compute_potential_qty',
|
||||
digits=dp.get_precision('Product Unit of Measure'),
|
||||
string='Potential',
|
||||
help="Quantity of this Product that could be produced using "
|
||||
"the materials already at hand. "
|
||||
"If the product has several variants, this will be the biggest "
|
||||
"quantity that can be made for a any single variant.")
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# © 2014 Numérigraphe, Sodexis
|
||||
# Copyright 2014 Numérigraphe
|
||||
# Copyright 2016 Sodexis
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
||||
|
||||
from openerp import api, models, fields
|
||||
from odoo import api, models, fields
|
||||
|
||||
|
||||
class StockConfig(models.TransientModel):
|
||||
|
||||
BIN
stock_available/static/description/icon.png
Normal file
BIN
stock_available/static/description/icon.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 9.2 KiB |
6
stock_available/tests/__init__.py
Normal file
6
stock_available/tests/__init__.py
Normal file
@@ -0,0 +1,6 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Copyright 2014 Numérigraphe
|
||||
# Copyright 2016 Sodexis
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
||||
|
||||
from . import test_stock_available
|
||||
22
stock_available/tests/test_stock_available.py
Normal file
22
stock_available/tests/test_stock_available.py
Normal file
@@ -0,0 +1,22 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Copyright 2014 Numérigraphe
|
||||
# Copyright 2016 Sodexis
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
||||
|
||||
from odoo.tests.common import TransactionCase
|
||||
|
||||
|
||||
class TestStockLogisticsWarehouse(TransactionCase):
|
||||
|
||||
def test_res_config(self):
|
||||
"""Test the config file"""
|
||||
stock_setting = self.env['stock.config.settings'].create({})
|
||||
|
||||
self.assertEquals(
|
||||
stock_setting.stock_available_mrp_based_on,
|
||||
'qty_available')
|
||||
stock_setting.stock_available_mrp_based_on = 'immediately_usable_qty'
|
||||
stock_setting.set_stock_available_mrp_based_on()
|
||||
self.assertEquals(
|
||||
stock_setting.stock_available_mrp_based_on,
|
||||
'immediately_usable_qty')
|
||||
@@ -1,9 +1,9 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- © 2014 Numérigraphe, Sodexis
|
||||
<!-- Copyright 2014 Numérigraphe
|
||||
Copyright 2016 Sodexis
|
||||
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). -->
|
||||
|
||||
<openerp>
|
||||
<data>
|
||||
<odoo>
|
||||
<record model="ir.ui.view" id="product_normal_form_view">
|
||||
<field name="name">Quantity available to promise (variant tree)</field>
|
||||
<field name="model">product.product</field>
|
||||
@@ -12,7 +12,7 @@
|
||||
<xpath expr="//button[@name='%(stock.action_stock_level_forecast_report_product)d']"
|
||||
position="after">
|
||||
<button type="action" name="%(stock.product_open_quants)d"
|
||||
attrs="{'invisible':[('type', '!=', 'product')]}"
|
||||
attrs="{'invisible':[('type', 'not in', ['product','consu'])]}"
|
||||
class="oe_stat_button" icon="fa-building-o">
|
||||
<div class="o_form_field o_stat_info">
|
||||
<field name="immediately_usable_qty"
|
||||
@@ -20,8 +20,16 @@
|
||||
<span class="o_stat_text">Available</span>
|
||||
</div>
|
||||
</button>
|
||||
<button type="action" name="%(stock.product_open_quants)d"
|
||||
attrs="{'invisible':[('type', 'not in', ['product','consu'])]}"
|
||||
class="oe_stat_button" icon="fa-building-o">
|
||||
<div class="o_form_field o_stat_info">
|
||||
<field name="potential_qty"
|
||||
widget="statinfo" nolabel="1"/>
|
||||
<span class="o_stat_text">Potential</span>
|
||||
</div>
|
||||
</button>
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
</data>
|
||||
</openerp>
|
||||
</odoo>
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- © 2014 Numérigraphe, Sodexis
|
||||
<!-- Copyright 2014 Numérigraphe
|
||||
Copyright 2016 Sodexis
|
||||
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). -->
|
||||
|
||||
<openerp>
|
||||
<data>
|
||||
<odoo>
|
||||
<record model="ir.ui.view" id="view_stock_available_form">
|
||||
<field name="name">Quantity available to promise (form)</field>
|
||||
<field name="model">product.template</field>
|
||||
@@ -12,7 +12,7 @@
|
||||
<xpath expr="//button[@name='%(stock.action_stock_level_forecast_report_template)d']"
|
||||
position="after">
|
||||
<button type="object" name="action_open_quants"
|
||||
attrs="{'invisible':[('type', '!=', 'product')]}"
|
||||
attrs="{'invisible':[('type', 'not in', ['product','consu'])]}"
|
||||
class="oe_stat_button" icon="fa-building-o">
|
||||
<div class="o_form_field o_stat_info">
|
||||
<field name="immediately_usable_qty"
|
||||
@@ -20,6 +20,15 @@
|
||||
<span class="o_stat_text">Available</span>
|
||||
</div>
|
||||
</button>
|
||||
<button type="action" name="%(stock.product_open_quants)d"
|
||||
attrs="{'invisible':[('type', 'not in', ['product','consu'])]}"
|
||||
class="oe_stat_button" icon="fa-building-o">
|
||||
<div class="o_form_field o_stat_info">
|
||||
<field name="potential_qty"
|
||||
widget="statinfo" nolabel="1"/>
|
||||
<span class="o_stat_text">Potential</span>
|
||||
</div>
|
||||
</button>
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
@@ -29,7 +38,8 @@
|
||||
<field name="inherit_id" ref="stock.view_stock_product_template_tree"/>
|
||||
<field name="arch" type="xml">
|
||||
<tree position="attributes">
|
||||
<attribute name="colors">red:immediately_usable_qty<0;blue:immediately_usable_qty>=0 and state in ('draft', 'end', 'obsolete');black:immediately_usable_qty>=0 and state not in ('draft', 'end', 'obsolete')</attribute>
|
||||
<attribute name="decoration-danger">virtual_available<0 or immediately_usable_qty<0</attribute>
|
||||
<attribute name="decoration-info">virtual_available>=0 or immediately_usable_qty>0</attribute>
|
||||
</tree>
|
||||
<field name="virtual_available" position="after">
|
||||
<field name="immediately_usable_qty" />
|
||||
@@ -46,5 +56,4 @@
|
||||
</ul>
|
||||
</field>
|
||||
</record>
|
||||
</data>
|
||||
</openerp>
|
||||
</odoo>
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- © 2014 Numérigraphe, Sodexis
|
||||
<!-- Copyright 2014 Numérigraphe
|
||||
Copyright 2016 Sodexis
|
||||
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). -->
|
||||
|
||||
<openerp>
|
||||
<data>
|
||||
<odoo>
|
||||
<record id="view_stock_configuration" model="ir.ui.view">
|
||||
<field name="name">Stock settings: quantity available to promise</field>
|
||||
<field name="model">stock.config.settings</field>
|
||||
@@ -35,5 +35,4 @@
|
||||
</data>
|
||||
</field>
|
||||
</record>
|
||||
</data>
|
||||
</openerp>
|
||||
</odoo>
|
||||
|
||||
Reference in New Issue
Block a user