Merge lp:~openerp-dev/openobject-addons/6.1-opw-576033-rgo into lp:openobject-addons/6.1

Proposed by Ravi Gohil (OpenERP)
Status: Rejected
Rejected by: Naresh(OpenERP)
Proposed branch: lp:~openerp-dev/openobject-addons/6.1-opw-576033-rgo
Merge into: lp:openobject-addons/6.1
Diff against target: 49 lines (+19/-9)
2 files modified
product/product.py (+0/-9)
stock/product.py (+19/-0)
To merge this branch: bzr merge lp:~openerp-dev/openobject-addons/6.1-opw-576033-rgo
Reviewer Review Type Date Requested Status
Naresh(OpenERP) (community) Disapprove
Ravi Gohil (OpenERP) (community) Needs Resubmitting
Review via email: mp+120982@code.launchpad.net

This proposal supersedes a proposal from 2012-06-20.

Description of the change

Hello,

If we just created a product and saved it, it is impossible to change the unit of the product with the unit which has other category than current unit's category.

Fix has been back-ported from the trunk branch: lp:~openerp-dev/openobject-addons/trunk-bug-894648-amp.

Kindly review the fix.

Thanks.

To post a comment you must log in.
Revision history for this message
Naresh(OpenERP) (nch-openerp) : Posted in a previous version of this proposal
review: Approve
Revision history for this message
Naresh(OpenERP) (nch-openerp) wrote : Posted in a previous version of this proposal

well this fix seems some what complicated when a user tries to update the field externally either through say xmlrpc script.

you check the category ID for old and new along with if the move exist or not
 product_move = self.pool.get('stock.move').search(cr, uid, [('product_id', '=', ids[0])])

but you do the move check for just the first product and not all the product that are to be written.

say for eg: I want product with ID 4,5 to change there default UOM from PCE to KM and I have stock move for the product 5. so actually this should not allow me to update but in your case it does.

can you please recheck.

Thanks,
Naresh

review: Needs Fixing
Revision history for this message
Ravi Gohil (OpenERP) (rgo-openerp) wrote :

Hello,

Thanks for the review.

I have updated the fix as suggested in above comment.

Please review the fix.

Thanks.

Revision history for this message
Ravi Gohil (OpenERP) (rgo-openerp) :
review: Needs Resubmitting
6961. By Ravi Gohil (OpenERP)

[FIX] product: Fixed the issue caused when multiple ids passed to write: (Maintenance Case : 576033)

Revision history for this message
Naresh(OpenERP) (nch-openerp) wrote :

only covers stock what about other modules where product is interacted like SO, PO inventories etc.....

review: Disapprove

Unmerged revisions

6961. By Ravi Gohil (OpenERP)

[FIX] product: Fixed the issue caused when multiple ids passed to write: (Maintenance Case : 576033)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'product/product.py'
--- product/product.py 2012-04-03 13:05:28 +0000
+++ product/product.py 2012-08-23 13:51:19 +0000
@@ -354,15 +354,6 @@
354 return {'value': {'uom_po_id': uom_id}}354 return {'value': {'uom_po_id': uom_id}}
355 return {}355 return {}
356356
357 def write(self, cr, uid, ids, vals, context=None):
358 if 'uom_po_id' in vals:
359 new_uom = self.pool.get('product.uom').browse(cr, uid, vals['uom_po_id'], context=context)
360 for product in self.browse(cr, uid, ids, context=context):
361 old_uom = product.uom_po_id
362 if old_uom.category_id.id != new_uom.category_id.id:
363 raise osv.except_osv(_('UoM categories Mismatch!'), _("New UoM '%s' must belong to same UoM category '%s' as of old UoM '%s'. If you need to change the unit of measure, you may desactivate this product from the 'Procurement & Locations' tab and create a new one.") % (new_uom.name, old_uom.category_id.name, old_uom.name,))
364 return super(product_template, self).write(cr, uid, ids, vals, context=context)
365
366 _defaults = {357 _defaults = {
367 'company_id': lambda s,cr,uid,c: s.pool.get('res.company')._company_default_get(cr, uid, 'product.template', context=c),358 'company_id': lambda s,cr,uid,c: s.pool.get('res.company')._company_default_get(cr, uid, 'product.template', context=c),
368 'list_price': lambda *a: 1,359 'list_price': lambda *a: 1,
369360
=== modified file 'stock/product.py'
--- stock/product.py 2012-06-19 07:40:07 +0000
+++ stock/product.py 2012-08-23 13:51:19 +0000
@@ -493,6 +493,25 @@
493 "there is a specific valuation account set on the destination location. When not set on the product, the one from the product category is used."),493 "there is a specific valuation account set on the destination location. When not set on the product, the one from the product category is used."),
494 }494 }
495495
496 def write(self, cr, uid, ids, vals, context=None):
497 if 'uom_po_id' in vals:
498 new_uom = self.pool.get('product.uom').browse(cr, uid, vals['uom_po_id'], context=context)
499 write_ids = []
500 warning = ""
501 for product in self.browse(cr, uid, ids, context=context):
502 product_move = self.pool.get('stock.move').search(cr, uid, [('product_id', '=', product.id)])
503 if product_move:
504 old_uom = product.uom_po_id
505 if old_uom.category_id.id != new_uom.category_id.id:
506 warning += _("Product's new UoM '%s' must belong to same UoM category '%s' as of old UoM '%s'.Because product %s 's stock move is already created'") % (new_uom.name, old_uom.category_id.name, old_uom.name, product.name) + "\n"
507 else:
508 write_ids.append(product.id)
509 else:
510 write_ids.append(product.id)
511 if warning:
512 raise osv.except_osv(_('UoM categories Mismatch!'), warning)
513 return super(product_template, self).write(cr, uid, write_ids, vals, context=context)
514
496product_template()515product_template()
497516
498class product_category(osv.osv):517class product_category(osv.osv):