openerp-dev-web team mailing list archive
-
openerp-dev-web team
-
Mailing list archive
-
Message #05921
[Merge] lp:~openerp-dev/openobject-addons/6.0-opw-4972-improved-ach into lp:openobject-addons/6.0
Anup(OpenERP) has proposed merging lp:~openerp-dev/openobject-addons/6.0-opw-4972-improved-ach into lp:openobject-addons/6.0.
Requested reviews:
Jay Vora (OpenERP) (jvo-openerp)
For more details, see:
https://code.launchpad.net/~openerp-dev/openobject-addons/6.0-opw-4972-improved-ach/+merge/59026
Hello Jay,
I have improved the wizard and other functionalities as suggested by you.
You can have the Previous discussion on https://code.launchpad.net/~openerp-dev/openobject-addons/6.0-opw-4972-ach/+merge/59021
Thanks.
--
https://code.launchpad.net/~openerp-dev/openobject-addons/6.0-opw-4972-improved-ach/+merge/59026
Your team OpenERP R&D Team is subscribed to branch lp:~openerp-dev/openobject-addons/6.0-opw-4972-improved-ach.
=== modified file 'stock/stock.py'
--- stock/stock.py 2011-04-18 05:13:22 +0000
+++ stock/stock.py 2011-04-26 07:24:34 +0000
@@ -2356,7 +2356,8 @@
}
if (not move.prodlot_id.id) and (move.product_id.track_production and location_id):
# IF product has checked track for production lot, move lines will be split by 1
- res += self.action_split(cr, uid, [move.id], quantity, split_by_qty=1, context=context)
+ split_by_qty = context.get('product_qty',1)
+ res += self.action_split(cr, uid, [move.id], quantity, split_by_qty=split_by_qty, context=context)
else:
current_move = self.copy(cr, uid, move.id, default_val)
res += [current_move]
@@ -2369,7 +2370,8 @@
quantity_rest = quantity
uos_qty_rest = uos_qty
if (not move.prodlot_id.id) and (move.product_id.track_production and location_id):
- res += self.action_split(cr, uid, [move.id], quantity_rest, split_by_qty=1, context=context)
+ split_by_qty = context.get('product_qty',1)
+ res += self.action_split(cr, uid, [move.id], quantity_rest, split_by_qty=split_by_qty, context=context)
else:
res += [move.id]
update_val = {
=== modified file 'stock/wizard/stock_move.py'
--- stock/wizard/stock_move.py 2011-04-01 05:25:48 +0000
+++ stock/wizard/stock_move.py 2011-04-26 07:24:34 +0000
@@ -23,6 +23,8 @@
import decimal_precision as dp
+from tools.translate import _
+
class stock_move_track(osv.osv_memory):
_name = "stock.move.track"
_description = "Track moves"
@@ -60,7 +62,9 @@
'product_id': fields.many2one('product.product', 'Product', required=True, select=True),
'product_qty': fields.float('Quantity', required=True),
'product_uom': fields.many2one('product.uom', 'Product UOM', required=True),
- 'location_id': fields.many2one('stock.location', 'Location', required=True)
+ 'location_id': fields.many2one('stock.location', 'Location', required=True),
+ 'prod_lot_id': fields.many2one('stock.production.lot','Production Lot'),
+ 'track':fields.dummy(string='Track',type='boolean')
}
def default_get(self, cr, uid, fields, context=None):
@@ -84,6 +88,9 @@
res.update({'product_qty': move.product_qty})
if 'location_id' in fields:
res.update({'location_id': move.location_id.id})
+ if 'prod_lot_id' in fields:
+ res.update({'prod_lot_id': move.prodlot_id.id})
+ res.update({'track':move.product_id.track_production})
return res
@@ -100,10 +107,21 @@
context = {}
move_obj = self.pool.get('stock.move')
move_ids = context['active_ids']
- for data in self.read(cr, uid, ids):
- move_obj.action_consume(cr, uid, move_ids,
- data['product_qty'], data['location_id'],
+ stock_moves = move_obj.browse(cr,uid,move_ids)
+ data = self.browse(cr, uid, ids[0])
+ for stock_move in stock_moves:
+
+ if stock_move.product_qty<data.product_qty:
+ raise osv.except_osv(_('User Error!'),_('Cannot consume more quantity of products than available!'))
+
+ if stock_move.prodlot_id != data.prod_lot_id:
+ move_obj.write(cr, uid, [stock_move.id], {'prodlot_id':data.prod_lot_id.id}, context=context)
+
+ context.update({'product_qty':data.product_qty})
+ move_obj.action_consume(cr, uid, [stock_move.id],
+ data.product_qty, data.location_id.id,
context=context)
+
return {'type': 'ir.actions.act_window_close'}
stock_move_consume()
=== modified file 'stock/wizard/stock_move_view.xml'
--- stock/wizard/stock_move_view.xml 2011-01-14 00:11:01 +0000
+++ stock/wizard/stock_move_view.xml 2011-04-26 07:24:34 +0000
@@ -43,6 +43,8 @@
<field name="location_id" colspan="4" />
<field name="product_qty" colspan="2"/>
<field name="product_uom" nolabel="1" readonly="1"/>
+ <field name="prod_lot_id" attrs="{'required':[('track','=',True)]}" domain="[('product_id','=',product_id)]"/>
+ <field name="track" invisible="1"/>
<newline/>
<separator string="" colspan="4" />
<label string="" colspan="2" />
Follow ups