openerp-community-reviewer team mailing list archive
-
openerp-community-reviewer team
-
Mailing list archive
-
Message #03738
[Merge] lp:~camptocamp/product-kitting/6.1-backport_bom_stock_fixes-afe into lp:product-kitting/6.1
Alexandre Fayolle - camptocamp has proposed merging lp:~camptocamp/product-kitting/6.1-backport_bom_stock_fixes-afe into lp:product-kitting/6.1.
Requested reviews:
Product Core Editors (product-core-editors)
Related bugs:
Bug #1279351 in Product - Kitting Management: "bom_stock: the quantity produced by the BOM is ignored"
https://bugs.launchpad.net/product-kitting/+bug/1279351
Bug #1279355 in Product - Kitting Management: "mrp_bom: missing dependency on mrp"
https://bugs.launchpad.net/product-kitting/+bug/1279355
Bug #1279383 in Product - Kitting Management: "bom_stock: wrong computed stock if BOM uses UOM which are different from product UOM"
https://bugs.launchpad.net/product-kitting/+bug/1279383
For more details, see:
https://code.launchpad.net/~camptocamp/product-kitting/6.1-backport_bom_stock_fixes-afe/+merge/205997
fix bom_stock issues
* reformat to 7.0 standards
* missing dependency on mrp
* use bom produced qty
* fix issues when the uom in the BOM are different from product UOM
* added a simple test. More of these needed, but that"s a start
--
https://code.launchpad.net/~camptocamp/product-kitting/6.1-backport_bom_stock_fixes-afe/+merge/205997
Your team Product Core Editors is requested to review the proposed merge of lp:~camptocamp/product-kitting/6.1-backport_bom_stock_fixes-afe into lp:product-kitting/6.1.
=== modified file 'bom_stock/__openerp__.py'
--- bom_stock/__openerp__.py 2012-02-22 10:06:26 +0000
+++ bom_stock/__openerp__.py 2014-02-12 16:03:37 +0000
@@ -24,15 +24,24 @@
'category': 'Generic Modules/Others',
'description':
"""Compute the BOM stock Value. BoM Stock Value are computed by:
- "(Reference stock" of "Product" + How much could I produce of That "Product" according to the component's "Reference Stock)"
- "This reference stock can be chosen by company through a selection field and can be one of the available stock quantity computed in the system : Available stock, Virtual stock, immediately_usable stock (from stock_available_immediately)"."""
+ (`Reference stock` of `Product` + How much could I produce of that `Product` according to the component's `Reference Stock`)
+
+ This reference stock can be chosen by company through a selection field
+ and can be one of the available stock quantity computed in the system :
+ Available stock, Virtual stock, immediately_usable stock (from
+ stock_available_immediately)."""
,
'author': 'Camptocamp',
'website': 'http://www.camptocamp.com',
- 'depends': ['stock', 'stock_available_immediately'],
+ 'depends': ['stock',
+ 'mrp',
+ 'stock_available_immediately',
+ ],
'init_xml': [],
'update_xml': ['bom_stock_view.xml'],
'demo_xml': [],
+ 'test': ['tests/test_bom_stock.yml',
+ ],
'installable': True,
'active': False,
}
=== modified file 'bom_stock/bom_stock.py'
--- bom_stock/bom_stock.py 2012-03-14 16:27:05 +0000
+++ bom_stock/bom_stock.py 2014-02-12 16:03:37 +0000
@@ -55,7 +55,7 @@
def _compute_bom_stock(self, cr, uid, product,
quantities, company, context=None):
bom_obj = self.pool.get('mrp.bom')
-
+ uom_obj = self.pool.get('product.uom')
mapping = self._bom_stock_mapping(cr, uid, context=context)
stock_field = mapping[company.ref_stock]
@@ -73,17 +73,17 @@
# get the minimal number of items we can produce with them
for line in bom.bom_lines:
prod_min_quantity = 0.0
- bom_qty = line.product_id[stock_field]
-
+ bom_qty = line.product_id[stock_field] # expressed in product UOM
# the reference stock of the component must be greater
# than the quantity of components required to
# build the bom
- if bom_qty >= line.product_qty:
- prod_min_quantity = (
- (bom_qty *
- line.product_id.uom_id.factor /
- line.product_uom.factor) /
- line.product_qty) # line.product_qty is always > 0
+ line_product_qty = uom_obj._compute_qty_obj(cr, uid,
+ line.product_uom,
+ line.product_qty,
+ line.product_id.uom_id,
+ context=context)
+ if bom_qty >= line_product_qty:
+ prod_min_quantity = bom_qty / line_product_qty # line.product_qty is always > 0
else:
# if one product has not enough stock,
# we do not need to compute next lines
@@ -91,11 +91,14 @@
stop_compute_bom = True
prod_min_quantities.append(prod_min_quantity)
-
if stop_compute_bom:
break
-
- product_qty += min(prod_min_quantities)
+ produced_qty = uom_obj._compute_qty_obj(cr, uid,
+ bom.product_uom,
+ bom.product_qty,
+ bom.product_id.uom_id,
+ context=context)
+ product_qty += min(prod_min_quantities) * produced_qty
return product_qty
def _product_available(self, cr, uid, ids, field_names=None,
=== modified file 'bom_stock/bom_stock_view.xml'
--- bom_stock/bom_stock_view.xml 2012-03-14 16:27:05 +0000
+++ bom_stock/bom_stock_view.xml 2014-02-12 16:03:37 +0000
@@ -9,10 +9,10 @@
<field name="arch" type="xml">
<field name="immediately_usable_qty" position="after">
<field name="bom_stock" />
- </field>
+ </field>
</field>
</record>
-
+
<record model="ir.ui.view" id="view_reference_stock_company_form">
<field name="name">res.company.reference.stock.form.inherit</field>
<field name="model">res.company</field>
@@ -22,7 +22,7 @@
<page string="Configuration" position="inside">
<separator string="Stock - Various" colspan="4"/>
<field name="ref_stock" />
- </page>
+ </page>
</field>
</record>
Follow ups