Merge lp:~vauxoo/addons-vauxoo/6.1_patch_product_in_raice_cons_prod_dev_luis into lp:addons-vauxoo

Proposed by Luis Torres - http://www.vauxoo.com
Status: Needs review
Proposed branch: lp:~vauxoo/addons-vauxoo/6.1_patch_product_in_raice_cons_prod_dev_luis
Merge into: lp:addons-vauxoo
Diff against target: 72 lines (+51/-1)
3 files modified
mrp_consume_produce/__openerp__.py (+1/-1)
mrp_consume_produce/patch/product_py.patch (+34/-0)
mrp_consume_produce/patch/stock_py.patch (+16/-0)
To merge this branch: bzr merge lp:~vauxoo/addons-vauxoo/6.1_patch_product_in_raice_cons_prod_dev_luis
Reviewer Review Type Date Requested Status
Rodolfo Lopez Pending
Review via email: mp+163234@code.launchpad.net

Description of the change

Se agregarón 2 parches, para aplicar en los addons de Open, para que agregue el nombre del producto cuando se quiere consumir la produccion, y la unidad de medida que se coloco al producto pertenece a otra categoria.

To post a comment you must log in.

Unmerged revisions

620. By Luis Torres - http://www.vauxoo.com

[ADD][mrp_consume_produce]Add files .patch

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'mrp_consume_produce/__openerp__.py'
2--- mrp_consume_produce/__openerp__.py 2012-09-18 22:20:16 +0000
3+++ mrp_consume_produce/__openerp__.py 2013-05-09 22:20:35 +0000
4@@ -31,7 +31,7 @@
5 "category": "Generic Modules/Production",
6 "website" : "http://www.vauxoo.com/",
7 "description": """ Add wizard to consume and produce.It will be necesary to apply the patch
8- patch/stock.patch located in this module ( useatch -b stock.py stock.patch )
9+ patch/stock.patch, product_py & stock_py located in this module ( useatch -b stock.py stock.patch )
10 """,
11 'depends': ['mrp'],
12 'init_xml': [],
13
14=== added file 'mrp_consume_produce/patch/product_py.patch'
15--- mrp_consume_produce/patch/product_py.patch 1970-01-01 00:00:00 +0000
16+++ mrp_consume_produce/patch/product_py.patch 2013-05-09 22:20:35 +0000
17@@ -0,0 +1,34 @@
18+=== modified file 'product/product.py'
19+--- product/product.py 2012-04-03 13:05:28 +0000
20++++ product/product.py 2013-05-09 20:38:53 +0000
21+@@ -125,7 +125,7 @@
22+ ('factor_gt_zero', 'CHECK (factor!=0)', 'The conversion ratio for a unit of measure cannot be 0!')
23+ ]
24+
25+- def _compute_qty(self, cr, uid, from_uom_id, qty, to_uom_id=False):
26++ def _compute_qty(self, cr, uid, from_uom_id, qty, to_uom_id=False, context=None):
27+ if not from_uom_id or not qty or not to_uom_id:
28+ return qty
29+ uoms = self.browse(cr, uid, [from_uom_id, to_uom_id])
30+@@ -133,14 +133,17 @@
31+ from_unit, to_unit = uoms[0], uoms[-1]
32+ else:
33+ from_unit, to_unit = uoms[-1], uoms[0]
34+- return self._compute_qty_obj(cr, uid, from_unit, qty, to_unit)
35++ return self._compute_qty_obj(cr, uid, from_unit, qty, to_unit, context=context)
36+
37+ def _compute_qty_obj(self, cr, uid, from_unit, qty, to_unit, context=None):
38+- if context is None:
39++ product_name = ''
40++ if context:
41++ product_name = context.get('product_name')
42++ else:
43+ context = {}
44+ if from_unit.category_id.id <> to_unit.category_id.id:
45+ if context.get('raise-exception', True):
46+- 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,))
47++ 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,))
48+ else:
49+ return qty
50+ amount = qty / from_unit.factor
51+
52
53=== added file 'mrp_consume_produce/patch/stock_py.patch'
54--- mrp_consume_produce/patch/stock_py.patch 1970-01-01 00:00:00 +0000
55+++ mrp_consume_produce/patch/stock_py.patch 2013-05-09 22:20:35 +0000
56@@ -0,0 +1,16 @@
57+=== modified file 'stock/stock.py'
58+--- stock/stock.py 2012-10-22 09:29:02 +0000
59++++ stock/stock.py 2013-05-09 20:35:01 +0000
60+@@ -2153,8 +2153,9 @@
61+ reference_currency_id = move.company_id.currency_id.id
62+
63+ default_uom = move.product_id.uom_id.id
64+- qty = product_uom_obj._compute_qty(cr, uid, move.product_uom.id, move.product_qty, default_uom)
65+-
66++ context.update({'product_name' : move.product_id.name})
67++ qty = product_uom_obj._compute_qty(cr, uid, move.product_uom.id, move.product_qty, default_uom, context=context)
68++ context.pop('product_name')
69+ # if product is set to average price and a specific value was entered in the picking wizard,
70+ # we use it
71+ if move.product_id.cost_method == 'average' and move.price_unit:
72+