##############################################################################
from openerp.osv import fields, osv
+from openerp.tools.translate import _
class product_category(osv.osv):
_inherit = "product.category"
help="This account will be used for invoices instead of the default one to value expenses for the current product."),
}
+ def write(self, cr, uid, ids, vals, context=None):
+ if 'uom_po_id' in vals:
+ product_ids = self.pool.get('product.product').search(cr, uid, [('product_tmpl_id', 'in', ids)], context=context)
+ if self.pool.get('account.move.line').search(cr, uid, [('product_id', 'in', product_ids)], context=context, limit=1):
+ raise osv.except_osv(_('Error!'), _("You can not change the unit of measure of a product that has been already used in an account journal item. If you need to change the unit of measure, you may deactivate this product.") % ())
+ return super(product_template, self).write(cr, uid, ids, vals, context=context)
+
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
''' Store the standard price change in order to be able to retrieve the cost of a product template for a given date'''
if isinstance(ids, (int, long)):
ids = [ids]
- 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,))
if 'standard_price' in vals:
for prod_template_id in ids:
self._set_standard_price(cr, uid, prod_template_id, vals['standard_price'], context=context)
result['context'] = "{'tree_view_ref':'stock.view_move_tree'}"
return result
+ def write(self, cr, uid, ids, vals, context=None):
+ if 'uom_po_id' in vals:
+ product_ids = self.pool.get('product.product').search(cr, uid, [('product_tmpl_id', 'in', ids)], context=context)
+ if self.pool.get('stock.move').search(cr, uid, [('product_id', 'in', product_ids)], context=context, limit=1):
+ raise osv.except_osv(_('Error!'), _("You can not change the unit of measure of a product that has already been used in a stock move. If you need to change the unit of measure, you may deactivate this product.") % ())
+ return super(product_template, self).write(cr, uid, ids, vals, context=context)
+
class product_removal_strategy(osv.osv):
_name = 'product.removal'
list_price: 100.0
standard_price: 70.0
uom_id: product.product_uom_kgm
- uom_po_id: product.product_uom_kgm
property_stock_inventory: location_inventory
description: Ice cream can be mass-produced and thus is widely available in developed parts of the world. Ice cream can be purchased in large cartons (vats and squrounds) from supermarkets and grocery stores, in smaller quantities from ice cream shops, convenience stores, and milk bars, and in individual servings from small carts or vans at public events.
-