Amit Parik (OpenERP) has proposed merging
lp:~openerp-dev/openobject-addons/trunk-bug-894648-amp into
lp:openobject-addons.
Requested reviews:
OpenERP Core Team (openerp)
Related bugs:
Bug #894648 in OpenERP Addons: "Can not change the product's UOM , If once I
have save the product"
https://bugs.launchpad.net/openobject-addons/+bug/894648
For more details, see:
https://code.launchpad.net/~openerp-dev/openobject-addons/trunk-bug-894648-amp/+merge/103980
Hello,
Steps:
Create product save it, try to change the uom of product with different
category. Warning is generated on write() method.
But this warning will only appear when product has a stock move otherwise it
will allow to change the UOM of product.
For more information please read the comments on bug report.
This fix will solve the porblem!
--
https://code.launchpad.net/~openerp-dev/openobject-addons/trunk-bug-894648-amp/+merge/103980
Your team OpenERP R&D Team is subscribed to branch
lp:~openerp-dev/openobject-addons/trunk-bug-894648-amp.
=== modified file 'product/product.py'
--- product/product.py 2012-04-06 12:37:32 +0000
+++ product/product.py 2012-04-28 13:35:23 +0000
@@ -354,15 +354,6 @@
return {'value': {'uom_po_id': uom_id}}
return {}
- def write(self, cr, uid, ids, vals, context=None):
- if 'uom_po_id' in vals:
- new_uom = self.pool.get('product.uom').browse(cr, uid, vals['uom_po_id'], context=context)
- for product in self.browse(cr, uid, ids, context=context):
- old_uom = product.uom_po_id
- if old_uom.category_id.id != new_uom.category_id.id:
- 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,))
- return super(product_template, self).write(cr, uid, ids, vals, context=context)
-
_defaults = {
'company_id': lambda s,cr,uid,c: s.pool.get('res.company')._company_default_get(cr, uid, 'product.template', context=c),
'list_price': lambda *a: 1,
=== modified file 'stock/product.py'
--- stock/product.py 2012-02-13 15:27:55 +0000
+++ stock/product.py 2012-04-28 13:35:23 +0000
@@ -488,6 +488,17 @@
help="When doing real-time inventory valuation, counterpart journal items for all outgoing stock moves will be posted in this account, unless "
"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."),
}
+
+ def write(self, cr, uid, ids, vals, context=None):
+ if 'uom_po_id' in vals:
+ new_uom = self.pool.get('product.uom').browse(cr, uid, vals['uom_po_id'], context=context)
+ product_move = self.pool.get('stock.move').search(cr, uid, [('product_id', '=', ids[0])])
+ for product in self.browse(cr, uid, ids, context=context):
+ old_uom = product.uom_po_id
+ if old_uom.category_id.id != new_uom.category_id.id and product_move:
+ raise osv.except_osv(_('UoM categories Mismatch!'), _("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))
+ return super(product_template, self).write(cr, uid, ids, vals, context=context)
+
product_template()
_______________________________________________
Mailing list: https://launchpad.net/~openerp-dev-gtk
Post to : [email protected]
Unsubscribe : https://launchpad.net/~openerp-dev-gtk
More help : https://help.launchpad.net/ListHelp