[IMP] stock: update product quantity on hand
Now, the button "Update Quantity" and the stat button "Qty. On Hand" on the product's form view will both call `action_update_quantity_on_hand`, which who can call `action_open_quants` is an advance option is enable (multilocation, owner or package) or if the product is tracked by lot or serial numbers. Also, displays the product's UoM in the `stock.change.product.qty` wizard and changes its style so labels have more space. task-3076044 Part-of: odoo/odoo#109511
This commit is contained in:
@@ -909,11 +909,10 @@ class ProductTemplate(models.Model):
|
||||
def action_update_quantity_on_hand(self):
|
||||
advanced_option_groups = [
|
||||
'stock.group_stock_multi_locations',
|
||||
'stock.group_production_lot',
|
||||
'stock.group_tracking_owner',
|
||||
'product.group_tracking_lot'
|
||||
'stock.group_tracking_lot'
|
||||
]
|
||||
if (self.env.user.user_has_groups(','.join(advanced_option_groups))):
|
||||
if (self.env.user.user_has_groups(','.join(advanced_option_groups))) or self.tracking != 'none':
|
||||
return self.action_open_quants()
|
||||
else:
|
||||
default_product_id = self.env.context.get('default_product_id', len(self.product_variant_ids) == 1 and self.product_variant_id.id)
|
||||
|
||||
@@ -258,7 +258,7 @@
|
||||
<field name="show_on_hand_qty_status_button" invisible="1"/>
|
||||
<field name="show_forecasted_qty_status_button" invisible="1"/>
|
||||
<button class="oe_stat_button"
|
||||
name="action_open_quants"
|
||||
name="action_update_quantity_on_hand"
|
||||
icon="fa-cubes"
|
||||
type="object"
|
||||
attrs="{'invisible':[('show_on_hand_qty_status_button', '=', False)]}">
|
||||
@@ -366,7 +366,7 @@
|
||||
<field name="show_on_hand_qty_status_button" invisible="1"/>
|
||||
<field name="show_forecasted_qty_status_button" invisible="1"/>
|
||||
<button type="object"
|
||||
name="action_open_quants"
|
||||
name="action_update_quantity_on_hand"
|
||||
attrs="{'invisible':[('show_on_hand_qty_status_button', '=', False)]}"
|
||||
class="oe_stat_button" icon="fa-cubes">
|
||||
<div class="o_field_widget o_stat_info">
|
||||
|
||||
@@ -16,6 +16,7 @@ class ProductChangeQuantity(models.TransientModel):
|
||||
'New Quantity on Hand', default=1,
|
||||
digits='Product Unit of Measure', required=True,
|
||||
help='This quantity is expressed in the Default Unit of Measure of the product.')
|
||||
product_uom_id = fields.Many2one(related='product_tmpl_id.uom_id')
|
||||
|
||||
@api.onchange('product_id')
|
||||
def _onchange_product_id(self):
|
||||
|
||||
@@ -6,16 +6,26 @@
|
||||
<field name="model">stock.change.product.qty</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Update Product Quantity">
|
||||
<group>
|
||||
<div class="container">
|
||||
<field name="product_tmpl_id" invisible="1"/>
|
||||
<field name="product_variant_count" invisible="1"/>
|
||||
<field name="product_id" options="{'no_open': True, 'no_create': True}"
|
||||
domain="[('product_tmpl_id', '=', product_tmpl_id)]"
|
||||
attrs="{'invisible': [('product_variant_count', '=', 1)]}"
|
||||
invisible="context.get('default_product_id')"
|
||||
readonly="context.get('default_product_id')"/>
|
||||
<field name="new_quantity"/>
|
||||
</group>
|
||||
<div class="row" invisible="context.get('default_product_id')">
|
||||
<label for="product_id" class="col-5 col-md-4 col-lg-3"/>
|
||||
<field name="product_id" class="col-6"
|
||||
options="{'no_open': True, 'no_create': True}"
|
||||
domain="[('product_tmpl_id', '=', product_tmpl_id)]"
|
||||
attrs="{'invisible': [('product_variant_count', '=', 1)]}"
|
||||
readonly="context.get('default_product_id')"/>
|
||||
</div>
|
||||
<div class="row">
|
||||
<label for="new_quantity" class="col-5 col-md-4 col-lg-3"/>
|
||||
<div class="col-6 col-md-5 col-lg-4 row">
|
||||
<field name="new_quantity" class="col-4 pe-0"/>
|
||||
<field name="product_uom_id" groups="uom.group_uom" options="{'no_open': True}"
|
||||
class="col-8 ps-2"/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<footer>
|
||||
<button name="change_product_qty" string="Apply" type="object" class="btn-primary" data-hotkey="q"/>
|
||||
<button string="Cancel" class="btn-secondary" special="cancel" data-hotkey="z"/>
|
||||
|
||||
Reference in New Issue
Block a user