diff --git a/stock_available_immediately/README.rst b/stock_available_immediately/README.rst new file mode 100644 index 000000000..5117d6025 --- /dev/null +++ b/stock_available_immediately/README.rst @@ -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) +* Lionel Sausin (Numérigraphe) + +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. diff --git a/stock_available_immediately/__openerp__.py b/stock_available_immediately/__openerp__.py index 1cedaa84f..197288c9b 100644 --- a/stock_available_immediately/__openerp__.py +++ b/stock_available_immediately/__openerp__.py @@ -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 } diff --git a/stock_available_immediately/product.py b/stock_available_immediately/product.py index 8e6a7dc95..05d8ad2e7 100644 --- a/stock_available_immediately/product.py +++ b/stock_available_immediately/product.py @@ -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') diff --git a/stock_available_immediately/product_view.xml b/stock_available_immediately/product_view.xml deleted file mode 100644 index bdd7873f9..000000000 --- a/stock_available_immediately/product_view.xml +++ /dev/null @@ -1,45 +0,0 @@ - - - - - - - - product.normal.stock.active.qty.form.inherit - product.template - - - - - - - - - - - - - - - product_immediately_usable.product_product_tree_view - product.template - - - - - 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') - - - - - - - - - -