mirror of
https://github.com/OCA/stock-logistics-warehouse.git
synced 2025-01-21 14:27:28 +02:00
[ADD] stock_available
Generic module to compute the stock quantity available to promise using several implementations. stock_available_immediatly is changed to become the first optional implementation. Cherry pick of commit0b060f619ffrom the v7 branch [IMP] stock_available* uses new API [IMP] READMEs and TODOs Cherry-picked from v7 at8add4bea7eConflicts: __unported__/stock_available_mrp/__openerp__.py stock_available/__openerp__.py stock_available_immediately/__openerp__.py
This commit is contained in:
committed by
Florian da Costa
parent
860db2bd89
commit
bc1a4c5e1c
30
stock_available_immediately/README.rst
Normal file
30
stock_available_immediately/README.rst
Normal file
@@ -0,0 +1,30 @@
|
||||
Ignore planned receptions in quantity available to promise
|
||||
==========================================================
|
||||
|
||||
Normally the quantity available to promise is based on the virtual stock,
|
||||
which includes both planned outgoing and incoming goods.
|
||||
This module will subtract the planned receptions from the quantity available to
|
||||
promise.
|
||||
|
||||
Credits
|
||||
=======
|
||||
|
||||
Contributors
|
||||
------------
|
||||
|
||||
* Author: Guewen Baconnier (Camptocamp SA)
|
||||
* Sébastien BEAU (Akretion) <sebastien.beau@akretion.com>
|
||||
* Lionel Sausin (Numérigraphe) <ls@numerigraphe.com>
|
||||
|
||||
Maintainer
|
||||
----------
|
||||
|
||||
.. image:: http://odoo-community.org/logo.png
|
||||
:alt: Odoo Community Association
|
||||
:target: http://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.
|
||||
|
||||
To contribute to this module, please visit http://odoo-community.org.
|
||||
@@ -20,21 +20,12 @@
|
||||
#
|
||||
#
|
||||
|
||||
|
||||
{
|
||||
"name": "Immediately Usable Stock Quantity",
|
||||
"version": "1.0",
|
||||
"depends": ["product", "stock", ],
|
||||
"name": "Ignore planned receptions in quantity available to promise",
|
||||
"version": "2.0",
|
||||
"depends": ["stock_available"],
|
||||
"author": "Camptocamp",
|
||||
"license": "AGPL-3",
|
||||
"description": """
|
||||
Compute the immediately usable stock.
|
||||
Immediately usable is computed : Quantity on Hand - Outgoing Stock.
|
||||
""",
|
||||
"website": "http://tinyerp.com/module_account.html",
|
||||
"category": "Generic Modules/Stock",
|
||||
"data": ["product_view.xml",
|
||||
],
|
||||
"active": False,
|
||||
"category": "Hidden",
|
||||
'installable': True
|
||||
}
|
||||
|
||||
@@ -19,106 +19,18 @@
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
from openerp.addons import decimal_precision as dp
|
||||
from openerp.osv import orm, fields
|
||||
from openerp import models, fields, api
|
||||
|
||||
|
||||
class ProductTemplate(orm.Model):
|
||||
"""
|
||||
Immediately usable quantity is : real stock - outgoing qty
|
||||
"""
|
||||
class ProductTemplate(models.Model):
|
||||
"""Subtract incoming qty from immediately_usable_qty"""
|
||||
_inherit = 'product.template'
|
||||
|
||||
def _product_available(self, cr, uid, ids, field_names=None,
|
||||
arg=False, context=None):
|
||||
res = super(ProductTemplate, self)._product_available(
|
||||
cr, uid, ids, field_names, arg, context)
|
||||
@api.depends('virtual_available')
|
||||
def _product_available(self):
|
||||
"""Ignore the incoming goods in the quantity available to promise"""
|
||||
super(ProductTemplate, self)._product_available()
|
||||
for product in self:
|
||||
product.immediately_usable_qty -= product.incoming_qty
|
||||
|
||||
if 'immediately_usable_qty' in field_names:
|
||||
for product_id, stock_qty in res.iteritems():
|
||||
res[product_id]['immediately_usable_qty'] = \
|
||||
stock_qty['qty_available'] - stock_qty['outgoing_qty']
|
||||
|
||||
return res
|
||||
|
||||
_columns = {
|
||||
'qty_available': fields.function(
|
||||
_product_available,
|
||||
multi='qty_available',
|
||||
type='float',
|
||||
digits_compute=dp.get_precision('Product UoM'),
|
||||
string='Quantity On Hand',
|
||||
help="Current quantity of products.\n"
|
||||
"In a context with a single Stock Location, this includes "
|
||||
"goods stored at this Location, or any of its children.\n"
|
||||
"In a context with a single Warehouse, this includes "
|
||||
"goods stored in the Stock Location of this Warehouse, "
|
||||
"or any "
|
||||
"of its children.\n"
|
||||
"In a context with a single Shop, this includes goods "
|
||||
"stored in the Stock Location of the Warehouse of this Shop, "
|
||||
"or any of its children.\n"
|
||||
"Otherwise, this includes goods stored in any Stock Location "
|
||||
"typed as 'internal'."),
|
||||
'virtual_available': fields.function(
|
||||
_product_available,
|
||||
multi='qty_available',
|
||||
type='float',
|
||||
digits_compute=dp.get_precision('Product UoM'),
|
||||
string='Quantity Available',
|
||||
help="Forecast quantity (computed as Quantity On Hand "
|
||||
"- Outgoing + Incoming)\n"
|
||||
"In a context with a single Stock Location, this includes "
|
||||
"goods stored at this Location, or any of its children.\n"
|
||||
"In a context with a single Warehouse, this includes "
|
||||
"goods stored in the Stock Location of this Warehouse, "
|
||||
"or any "
|
||||
"of its children.\n"
|
||||
"In a context with a single Shop, this includes goods "
|
||||
"stored in the Stock Location of the Warehouse of this Shop, "
|
||||
"or any of its children.\n"
|
||||
"Otherwise, this includes goods stored in any Stock Location "
|
||||
"typed as 'internal'."),
|
||||
'incoming_qty': fields.function(
|
||||
_product_available,
|
||||
multi='qty_available',
|
||||
type='float',
|
||||
digits_compute=dp.get_precision('Product UoM'),
|
||||
string='Incoming',
|
||||
help="Quantity of products that are planned to arrive.\n"
|
||||
"In a context with a single Stock Location, this includes "
|
||||
"goods arriving to this Location, or any of its children.\n"
|
||||
"In a context with a single Warehouse, this includes "
|
||||
"goods arriving to the Stock Location of this Warehouse, or "
|
||||
"any of its children.\n"
|
||||
"In a context with a single Shop, this includes goods "
|
||||
"arriving to the Stock Location of the Warehouse of this "
|
||||
"Shop, or any of its children.\n"
|
||||
"Otherwise, this includes goods arriving to any Stock "
|
||||
"Location typed as 'internal'."),
|
||||
'outgoing_qty': fields.function(
|
||||
_product_available,
|
||||
multi='qty_available',
|
||||
type='float',
|
||||
digits_compute=dp.get_precision('Product UoM'),
|
||||
string='Outgoing',
|
||||
help="Quantity of products that are planned to leave.\n"
|
||||
"In a context with a single Stock Location, this includes "
|
||||
"goods leaving from this Location, or any of its children.\n"
|
||||
"In a context with a single Warehouse, this includes "
|
||||
"goods leaving from the Stock Location of this Warehouse, or "
|
||||
"any of its children.\n"
|
||||
"In a context with a single Shop, this includes goods "
|
||||
"leaving from the Stock Location of the Warehouse of this "
|
||||
"Shop, or any of its children.\n"
|
||||
"Otherwise, this includes goods leaving from any Stock "
|
||||
"Location typed as 'internal'."),
|
||||
'immediately_usable_qty': fields.function(
|
||||
_product_available,
|
||||
digits_compute=dp.get_precision('Product UoM'),
|
||||
type='float',
|
||||
string='Immediately Usable',
|
||||
multi='qty_available',
|
||||
help="Quantity of products really available for sale."
|
||||
"Computed as: Quantity On Hand - Outgoing."),
|
||||
}
|
||||
immediately_usable_qty = fields.Float(compute='_product_available')
|
||||
|
||||
@@ -1,45 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<!--
|
||||
stock available_immediately for OpenERP
|
||||
Author Guewen Baconnier. Copyright Camptocamp SA
|
||||
Copyright (C) 2011 Akretion Sébastien BEAU <sebastien.beau@akretion.com>
|
||||
The licence is in the file __openerp__.py
|
||||
-->
|
||||
|
||||
<openerp>
|
||||
<data>
|
||||
<record model="ir.ui.view" id="view_normal_stock_active_qty_form">
|
||||
<field name="name">product.normal.stock.active.qty.form.inherit</field>
|
||||
<field name="model">product.template</field>
|
||||
<field name="inherit_id" ref="stock.view_template_property_form"/>
|
||||
<field name="arch" type="xml">
|
||||
<field name="virtual_available" position="before">
|
||||
<newline/>
|
||||
<field name="outgoing_qty" class="oe_inline"/>
|
||||
</field>
|
||||
<field name="virtual_available" position="after">
|
||||
<newline/>
|
||||
<field name="immediately_usable_qty" />
|
||||
</field>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record model="ir.ui.view" id="product_product_tree_view">
|
||||
<field name="name">product_immediately_usable.product_product_tree_view</field>
|
||||
<field name="model">product.template</field>
|
||||
<field name="inherit_id" ref="stock.view_stock_product_template_tree"/>
|
||||
<field name="arch" type="xml">
|
||||
<data>
|
||||
<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>
|
||||
</tree>
|
||||
<field name="virtual_available" position="replace">
|
||||
<field name="immediately_usable_qty" />
|
||||
</field>
|
||||
</data>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
</data>
|
||||
</openerp>
|
||||
Reference in New Issue
Block a user