[IMP] stock: on picking form inverse done and to do fields on operations and lots input
Also check for plus sign only to be visible when necessary, which makes quantity unnecessary when handling serial numbers
This commit is contained in:
+14
-7
@@ -4358,8 +4358,8 @@ class stock_pack_operation(osv.osv):
|
||||
'product_id': fields.many2one('product.product', 'Product', ondelete="CASCADE"), # 1
|
||||
'product_uom_id': fields.many2one('product.uom', 'Unit of Measure'),
|
||||
'product_qty': fields.float('To Do', digits_compute=dp.get_precision('Product Unit of Measure'), required=True),
|
||||
'qty_done': fields.float('Processed', digits_compute=dp.get_precision('Product Unit of Measure')),
|
||||
'processed_boolean': fields.function(_get_bool, fnct_inv=_set_processed_qty, type='boolean', string='Processed'),
|
||||
'qty_done': fields.float('Done', digits_compute=dp.get_precision('Product Unit of Measure')),
|
||||
'processed_boolean': fields.function(_get_bool, fnct_inv=_set_processed_qty, type='boolean', string='Done'),
|
||||
'package_id': fields.many2one('stock.quant.package', 'Source Package'), # 2
|
||||
'pack_lot_ids': fields.one2many('stock.pack.operation.lot', 'operation_id', 'Lots Used'),
|
||||
'result_package_id': fields.many2one('stock.quant.package', 'Destination Package', help="If set, the operations are packed into this package", required=False, ondelete='cascade'),
|
||||
@@ -4486,23 +4486,28 @@ class stock_pack_operation_lot(osv.osv):
|
||||
_name = "stock.pack.operation.lot"
|
||||
_description = "Specifies lot/serial number for pack operations that need it"
|
||||
|
||||
def _get_processed(self, cr, uid, ids, field_name, arg, context=None):
|
||||
def _get_plus(self, cr, uid, ids, field_name, arg, context=None):
|
||||
res = {}
|
||||
for packlot in self.browse(cr, uid, ids, context=context):
|
||||
res[packlot.id] = (packlot.qty > 0.0)
|
||||
if packlot.operation_id.product_id.tracking == 'serial':
|
||||
res[packlot.id] = (packlot.qty == 0.0)
|
||||
else:
|
||||
res[packlot.id] = (packlot.qty_todo == 0.0) or (packlot.qty < packlot.qty_todo)
|
||||
return res
|
||||
|
||||
_columns = {
|
||||
'operation_id': fields.many2one('stock.pack.operation'),
|
||||
'qty': fields.float('Quantity'),
|
||||
'qty': fields.float('Done'),
|
||||
'lot_id': fields.many2one('stock.production.lot', 'Lot/Serial Number'),
|
||||
'lot_name': fields.char('Lot Name'),
|
||||
'qty_todo': fields.float('Quantity'),
|
||||
'processed': fields.function(_get_processed, type='boolean', store={'stock.pack.operation.lot': (lambda self, cr, uid, ids ,c={}:ids, ['qty'], 10)}),
|
||||
'qty_todo': fields.float('To Do'),
|
||||
'plus_visible': fields.function(_get_plus, type='boolean'),
|
||||
}
|
||||
|
||||
_defaults = {
|
||||
'qty': lambda cr, uid, ids, c: 1.0,
|
||||
'qty_todo': lambda cr, uid, ids, c: 0.0,
|
||||
'plus_visible': True,
|
||||
}
|
||||
|
||||
def _check_lot(self, cr, uid, ids, context=None):
|
||||
@@ -4525,12 +4530,14 @@ class stock_pack_operation_lot(osv.osv):
|
||||
def do_plus(self, cr, uid, ids, context=None):
|
||||
for packlot in self.browse(cr, uid, ids, context=context):
|
||||
self.write(cr, uid, [packlot.id], {'qty': packlot.qty + 1}, context=context)
|
||||
self.pool['stock.pack.operation'].write(cr, uid, [packlot.operation_id.id], {'qty_done': packlot.operation_id.qty_done + 1}, context=context)
|
||||
pack = self.browse(cr, uid, ids[0], context=context).operation_id.id
|
||||
return self.pool['stock.pack.operation'].split_lot(cr, uid, [pack], context=context)
|
||||
|
||||
def do_minus(self, cr, uid, ids, context=None):
|
||||
for packlot in self.browse(cr, uid, ids, context=context):
|
||||
self.write(cr, uid, [packlot.id], {'qty': packlot.qty - 1}, context=context)
|
||||
self.pool['stock.pack.operation'].write(cr, uid, [packlot.operation_id.id], {'qty_done': packlot.operation_id.qty_done - 1}, context=context)
|
||||
pack = self.browse(cr, uid, ids[0], context=context).operation_id.id
|
||||
return self.pool['stock.pack.operation'].split_lot(cr, uid, [pack], context=context)
|
||||
|
||||
|
||||
@@ -757,16 +757,16 @@
|
||||
</group>
|
||||
<group>
|
||||
<field name="pack_lot_ids" nolabel="1" attrs="{'readonly': [('state', '=', 'done')]}">
|
||||
<tree editable="bottom" decoration-success="qty_todo==qty">
|
||||
<tree editable="bottom" decoration-success="qty_todo==qty" decoration-danger="(qty_todo > 0) and (qty>qty_todo)">
|
||||
<field name="lot_name" invisible="not context.get('only_create', False)"/>
|
||||
<field name="lot_id" invisible="context.get('only_create', False)"
|
||||
domain="[('product_id','=', parent.product_id)]"
|
||||
context="{'product_id': parent.product_id}"/>
|
||||
<field name="qty" invisible="context.get('serial') and context.get('only_create')"/>
|
||||
<field name="qty_todo" invisible="not context.get('show_reserved') or context.get('serial')" readonly="1"/>
|
||||
<field name="qty" invisible="context.get('serial')"/>
|
||||
<button name="do_minus" type="object" icon="fa-minus-square" attrs="{'invisible': [('qty', '<=', 0.99)]}" invisible="not context.get('show_reserved')"/>
|
||||
<button name="do_plus" type="object" icon="fa-plus-square" invisible="not context.get('show_reserved')"/>
|
||||
<field name="qty_todo" invisible="not context.get('show_reserved') or context.get('serial')" readonly="1" string="To Do"/>
|
||||
<field name="processed" invisible="1"/>
|
||||
<button name="do_plus" type="object" icon="fa-plus-square" attrs="{'invisible': [('plus_visible', '=', False)]}" invisible="not context.get('show_reserved')"/>
|
||||
<field name="plus_visible" invisible="1"/>
|
||||
</tree>
|
||||
</field>
|
||||
</group>
|
||||
@@ -843,10 +843,10 @@
|
||||
<field name="to_loc" groups="stock.group_locations,stock.group_tracking_lot"/>
|
||||
<field name="result_package_id" groups="stock.group_tracking_lot" context="{'location_id': location_dest_id}" invisible="1"/>
|
||||
<field name="state" invisible="1"/>
|
||||
<field name="product_qty" readonly="1" attrs="{'required': [('product_id', '!=', False)]}"/>
|
||||
<field name="qty_done" attrs="{'readonly': [('lots_visible', '=', True)]}"/>
|
||||
<button name="split_lot" string="Lot Split" type="object" icon="fa-list" groups="stock.group_production_lot"
|
||||
attrs="{'invisible': ['|', ('lots_visible', '=', False), ('state', 'not in', ['confirmed', 'assigned', 'waiting', 'partially_available','done'])]}"/>
|
||||
<field name="product_qty" readonly="1" attrs="{'required': [('product_id', '!=', False)]}"/>
|
||||
<button name="show_details" string="Modify" type="object" icon="fa-pencil" groups="stock.group_locations"
|
||||
states="confirmed,assigned,waiting,partially_available"/>
|
||||
</tree>
|
||||
|
||||
Reference in New Issue
Block a user