Commit 06ff74ce authored by Luis Ernesto Torres Macías's avatar Luis Ernesto Torres Macías
Browse files

[ADD][mrp_consume_produce]Add files .patch

parent 04f84acd
......@@ -31,7 +31,7 @@
"category": "Generic Modules/Production",
"website" : "http://www.vauxoo.com/",
"description": """ Add wizard to consume and produce.It will be necesary to apply the patch
patch/stock.patch located in this module ( useatch -b stock.py stock.patch )
patch/stock.patch, product_py & stock_py located in this module ( useatch -b stock.py stock.patch )
""",
'depends': ['mrp'],
'init_xml': [],
......
=== modified file 'product/product.py'
--- product/product.py 2012-04-03 13:05:28 +0000
+++ product/product.py 2013-05-09 20:38:53 +0000
@@ -125,7 +125,7 @@
('factor_gt_zero', 'CHECK (factor!=0)', 'The conversion ratio for a unit of measure cannot be 0!')
]
- def _compute_qty(self, cr, uid, from_uom_id, qty, to_uom_id=False):
+ def _compute_qty(self, cr, uid, from_uom_id, qty, to_uom_id=False, context=None):
if not from_uom_id or not qty or not to_uom_id:
return qty
uoms = self.browse(cr, uid, [from_uom_id, to_uom_id])
@@ -133,14 +133,17 @@
from_unit, to_unit = uoms[0], uoms[-1]
else:
from_unit, to_unit = uoms[-1], uoms[0]
- return self._compute_qty_obj(cr, uid, from_unit, qty, to_unit)
+ return self._compute_qty_obj(cr, uid, from_unit, qty, to_unit, context=context)
def _compute_qty_obj(self, cr, uid, from_unit, qty, to_unit, context=None):
- if context is None:
+ product_name = ''
+ if context:
+ product_name = context.get('product_name')
+ else:
context = {}
if from_unit.category_id.id <> to_unit.category_id.id:
if context.get('raise-exception', True):
- raise osv.except_osv(_('Error !'), _('Conversion from Product UoM %s to Default UoM %s is not possible as they both belong to different Category!.') % (from_unit.name,to_unit.name,))
+ raise osv.except_osv(_('Error !'), _('Conversion from Product UoM %s of product %s to Default UoM %s is not possible as they both belong to different Category!.') % (from_unit.name, product_name, to_unit.name,))
else:
return qty
amount = qty / from_unit.factor
=== modified file 'stock/stock.py'
--- stock/stock.py 2012-10-22 09:29:02 +0000
+++ stock/stock.py 2013-05-09 20:35:01 +0000
@@ -2153,8 +2153,9 @@
reference_currency_id = move.company_id.currency_id.id
default_uom = move.product_id.uom_id.id
- qty = product_uom_obj._compute_qty(cr, uid, move.product_uom.id, move.product_qty, default_uom)
-
+ context.update({'product_name' : move.product_id.name})
+ qty = product_uom_obj._compute_qty(cr, uid, move.product_uom.id, move.product_qty, default_uom, context=context)
+ context.pop('product_name')
# if product is set to average price and a specific value was entered in the picking wizard,
# we use it
if move.product_id.cost_method == 'average' and move.price_unit:
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment