Skip to Content
Menú
This question has been flagged
1 Respondre
12727 Vistes

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

Avatar
Descartar
Best Answer

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.

Avatar
Descartar
Related Posts Respostes Vistes Activitat
2
de set. 25
634
1
d’oct. 25
745
2
de juny 25
2288
0
de març 25
2205
0
de febr. 25
1637