Odoo Help

0

Change unit of measure

By
Elevenmidia
on 2/12/14, 6:28 AM 3,650 views

Dear all,

I have several products with a wrong unit of measure. They are registered as UN but they must be KG. Whe I try to change the unit of measure on the product form, I get an error when I try to save. The error is related to unit of measure categories mismatch. The error is:

"Unit of Measure categories Mismatch! New Unit of Measure 'kg' must belong to same Unit of Measure category 'Unit' as of old Unit of Measure 'Unit(s)'. If you need to change the unit of measure, you may deactivate this product from the 'Procurements' tab and create a new one. "

The proposed solution is usefull if we hava a small number of products to be changed or if the product has no stock moves. If we have lots of products to change and if some of them has some moves, this is not a solution because we will loose important information about the original product.

Is there any way to bypass the error message and change the unit of measure?

Thank you very much Paulo Matos

3
Prakash
On 2/12/14, 7:14 AM

1) In addons\product\product.py File

Temporary uncomment the line and then restart the server after that change UOM

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(_('Unit of Measure categories Mismatch!'), _("New Unit of Measure '%s' must belong to same Unit of Measure category '%s' as of old Unit of Measure '%s'. If you need to change the unit of measure, you may deactivate this product from the 'Procurements' 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)

OR

2) Change the Product UOM in database using SQL Update query

But it may be affect the functionality for the old product sale order done with uom units.

About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

Register

Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

0 follower(s)

Stats

Asked: 2/12/14, 6:28 AM
Seen: 3650 times
Last updated: 10/28/15, 5:50 AM