119
120
'production_ids': fields.many2many('mrp.production', 'mrp_production_move_ids', 'move_id', 'production_id', 'Related Production'),
120
121
'parent_bom_id':fields.many2one("mrp.bom",'Related Bom')
123
def onchange_quantity(self, cr, uid, ids, product_id, product_qty,
124
product_uom, product_uos):
125
""" On change of product quantity finds UoM and UoS quantities
126
@param product_id: Product id
127
@param product_qty: Changed Quantity of product
128
@param product_uom: Unit of measure of product
129
@param product_uos: Unit of sale of product
130
@return: Dictionary of values
132
result=super(StockMove,self).onchange_quantity(cr, uid, ids, product_id, product_qty, product_uom, product_uos)
134
if (not product_id) or (product_qty <=0.0):
137
product_obj = self.pool.get('product.product').browse(cr, uid, [product_id])[0]
138
uom2 = product_obj.uom_id
139
if (product_obj.type=='product') and (product_obj.virtual_available * uom2.factor < product_qty * product_obj.uom_id.factor) \
140
and (product_obj.procure_method=='make_to_stock'):
142
'title': _('Not enough stock !'),
143
'message': _('You plan to move %.2f %s but you only have %.2f %s available !\nThe real stock is %.2f %s. (without reservations)') %
144
(product_qty, uom2 and uom2.name or product_obj.uom_id.name,
145
max(0,product_obj.virtual_available), product_obj.uom_id.name,
146
max(0,product_obj.qty_available), product_obj.uom_id.name)
148
result['warning'] = warning
150
if (product_obj.type=='product') and product_obj.procure_method=='make_to_order':
151
bom_id = self.pool.get('mrp.bom').search(cr, uid, [
152
('product_id', '=', product_obj.id),
153
('bom_id', '=', False),
154
('type', '=', 'assembly')])[0]
155
bom_obj = self.pool.get('mrp.bom').browse(cr, uid, bom_id)
157
if bom_obj and (bom_obj.bom_stock_value < product_qty * product_obj.uom_id.factor) \
158
and (product_obj.procure_method=='make_to_order'):
160
'title': _('Not enough stock !'),
161
'message': _('You plan to move %.2f %s but you only have %.2f %s available !\nThe real stock is %.2f %s. (without reservations)') %
162
(product_qty, uom2 and uom2.name or product_obj.uom_id.name,
163
max(0,bom_obj.bom_stock_value), product_obj.uom_id.name,
164
max(0,product_obj.qty_available), product_obj.uom_id.name)
166
result['warning'] = warning
169
def onchange_product_id(self, cr, uid, ids, prod_id=False, loc_id=False,
170
loc_dest_id=False, address_id=False,product_qty=0):
171
""" On change of product id, .
172
@param prod_id: Changed Product id
173
@param loc_id: Source location id
174
@param loc_id: Destination location id
175
@param address_id: Address id of partner
176
@param product_qty: Product Quantity
177
@return: Dictionary of values
180
res=super(StockMove,self).onchange_product_id(cr, uid, ids, prod_id=prod_id, loc_id=loc_id,
181
loc_dest_id=loc_dest_id, address_id=address_id)
185
product_obj = self.pool.get('product.product').browse(cr, uid, [prod_id])[0]
186
uom2 = product_obj.uom_id
191
if (product_obj.type=='product') and (product_obj.virtual_available * uom2.factor < product_qty * product_obj.uom_id.factor) \
192
and (product_obj.procure_method=='make_to_stock'):
194
'title': _('Not enough stock !'),
195
'message': _('You plan to move %.2f %s but you only have %.2f %s available !\nThe real stock is %.2f %s. (without reservations)') %
196
(product_qty, uom2 and uom2.name or product_obj.uom_id.name,
197
max(0,product_obj.virtual_available), product_obj.uom_id.name,
198
max(0,product_obj.qty_available), product_obj.uom_id.name)
200
res['warning'] = warning
201
if (product_obj.type=='product') and product_obj.procure_method=='make_to_order':
202
bom_id = self.pool.get('mrp.bom').search(cr, uid, [
203
('product_id', '=', product_obj.id),
204
('bom_id', '=', False),
205
('type', '=', 'assembly')])[0]
206
bom_obj = self.pool.get('mrp.bom').browse(cr, uid, bom_id)
207
if bom_id and (bom_obj.bom_stock_value < product_qty * product_obj.uom_id.factor):
209
'title': _('Not enough stock !'),
210
'message': _('You plan to move %.2f %s but you only have %.2f %s available !\nThe real stock is %.2f %s. (without reservations)') %
211
(product_qty, uom2 and uom2.name or product_obj.uom_id.name,
212
max(0,bom_obj.bom_stock_value), product_obj.uom_id.name,
213
max(0,product_obj.qty_available), product_obj.uom_id.name)
215
res['warning'] = warning
218
'date': lambda *a: time.strftime('%Y-%m-%d %H:%M:%S'),
219
'date_expected': lambda *a: time.strftime('%Y-%m-%d %H:%M:%S'),