[IMP] stock: picking validate button + onchange uom

The button Mark As Todo should be before the button Validate because
most people check things when they transfer stuff in their warehouse.
Moreover, it creates confusion, because people will think Validate means Confirm
(or Mark As Todo).

When validating an empty picking, it will give an error now.

On_change of product on stock moves and pack operations should return
a domain for the UoM.
This commit is contained in:
Josse Colpaert
2015-09-08 15:25:16 +02:00
parent 058d0df3bd
commit 54fdc8576e
4 changed files with 17 additions and 10 deletions
+10 -4
View File
@@ -1528,6 +1528,8 @@ class stock_picking(models.Model):
data_obj = self.pool['ir.model.data']
for pick in self.browse(cr, uid, ids, context=context):
to_delete = []
if not pick.move_lines and not pick.pack_operation_ids:
raise UserError(_('Please create some Initial Demand or Mark as Todo and create some Operations. '))
# In draft or with no pack operations edited yet, ask if we can just do everything
if pick.state == 'draft' or all([x.qty_done == 0.0 for x in pick.pack_operation_ids]):
# If no lots when needed, raise error
@@ -2155,7 +2157,7 @@ class stock_move(osv.osv):
@return: Dictionary of values
"""
if not prod_id:
return {}
return {'domain': {'product_uom': []}}
user = self.pool.get('res.users').browse(cr, uid, uid)
lang = user and user.lang or False
if partner_id:
@@ -2174,7 +2176,10 @@ class stock_move(osv.osv):
result['location_id'] = loc_id
if loc_dest_id:
result['location_dest_id'] = loc_dest_id
return {'value': result}
res = {'value': result,
'domain': {'product_uom': [('category_id', '=', product.uom_id.category_id.id)]}
}
return res
def _prepare_picking_assign(self, cr, uid, move, context=None):
""" Prepares a new picking for this move as it could not be assigned to
@@ -4239,7 +4244,9 @@ class stock_pack_operation(osv.osv):
res['value']['product_uom_id'] = product.uom_id.id
if product:
res['value']['lots_visible'] = (product.tracking != 'none')
res['domain'] = {'product_uom': [('category_id','=',product.uom_id.category_id.id)]}
res['domain'] = {'product_uom_id': [('category_id','=',product.uom_id.category_id.id)]}
else:
res['domain'] = {'product_uom_id': []}
return res
def on_change_tests(self, cr, uid, ids, product_id, product_uom_id, product_qty, context=None):
@@ -4410,7 +4417,6 @@ class stock_pack_operation(osv.osv):
view = data_obj.xmlid_to_res_id(cr, uid, 'stock.view_pack_operation_lot_form')
only_create = picking_type.use_create_lots and not picking_type.use_existing_lots
show_reserved = any([x for x in pack.pack_lot_ids if x.qty_todo > 0.0])
ctx.update({'serial': serial,
'only_create': only_create,
'show_reserved': show_reserved})
+2 -3
View File
@@ -801,16 +801,16 @@
<field name="arch" type="xml">
<form string="Transfer">
<header>
<button name="do_new_transfer" states="draft,partially_available,assigned" string="Validate" groups="stock.group_stock_user" type="object" class="oe_highlight"/>
<button name="action_confirm" states="draft" string="Mark as Todo" type="object" class="oe_highlight" groups="base.group_user"/>
<button name="action_assign" states="confirmed,waiting" string="Reserve" type="object" class="oe_highlight" groups="base.group_user"/>
<button name="force_assign" states="confirmed,waiting,partially_available" string="Force Availability" type="object" groups="base.group_user"/>
<button name="do_new_transfer" states="draft,partially_available,assigned" string="Validate" groups="stock.group_stock_user" type="object" class="oe_highlight"/>
<button name="do_print_picking" string="Print Picking List" groups="stock.group_stock_user" type="object" attrs="{'invisible': [('state', 'not in', ('assigned', 'partially_available'))]}"/>
<button name="%(act_stock_return_picking)d" string="Reverse Transfer" states="done" type="action" groups="base.group_user"/>
<button name="action_cancel" states="assigned,confirmed,partially_available,draft,waiting" string="Cancel Transfer" groups="base.group_user" type="object"/>
<button name="do_unreserve" string="Unreserve" groups="base.group_user" type="object" attrs="{'invisible': [('quant_reserved_exist', '=', False)]}"/>
<button name="do_prepare_partial" attrs="{'invisible': ['|', ('launch_pack_operations', '=', True), '|', ('state', 'not in', ('assigned', 'partially_available')), ('pack_operation_ids', '!=', [])]}"
string="Proceed..." type="object"/>
string="Reset Operations" type="object"/>
<field name="launch_pack_operations" invisible="1"/>
<field name="state" widget="statusbar" statusbar_visible="draft,confirmed,partially_available,assigned,done" statusbar_colors='{"shipping_except":"red","invoice_except":"red","waiting_date":"blue"}'/>
</header>
@@ -1280,7 +1280,6 @@
<field name="product_uom_qty" on_change="onchange_quantity(product_id, product_uom_qty, product_uom)"/>
<field name="product_uom" options="{'no_open': True, 'no_create': True}" string="Unit of Measure" groups="product.group_uom"/>
<field name="location_id" invisible="1"/>
<field name="picking_id" invisible="1"/>
<field name="create_date" invisible="1" />
<field name="date_expected" invisible="1" />
<button name="%(stock.move_scrap)d"
@@ -6,7 +6,9 @@
<field name="arch" type="xml">
<form string="Backorder creation">
<group>
Do we need to create a backorder?
<p>
You supplied less products than provided in the Initial Demand. Do you want a backorder?
</p>
</group>
<footer>
<button name="process" string="Create Backorder" type="object" class="oe_highlight"/>
@@ -4,10 +4,10 @@
<field name="name">view_immediate_transfer</field>
<field name="model">stock.immediate.transfer</field>
<field name="arch" type="xml">
<form string="Everything at once?">
<form string="Immediate transfer?">
<group>
<p>
Click apply if you want to process everything at once.
Click apply if you want to do the transfer right away without checking the quantities.
</p>
</group>
<footer>