diff --git a/product_combo_pack/models/product_template.py b/product_combo_pack/models/product_template.py index 4d70a52e7..2669560c9 100644 --- a/product_combo_pack/models/product_template.py +++ b/product_combo_pack/models/product_template.py @@ -93,6 +93,7 @@ class ProductPack(models.Model): """Update the list price of the product with the pack price.""" self.list_price = self.pack_price + def get_quantity(self): """Calculate the pack quantity based on the availability of pack products.""" @@ -125,12 +126,13 @@ class ProductPack(models.Model): if not location_id: raise UserError(_( 'You need to select the location to update the pack quantity...!')) - self.env['stock.quant'].with_context(inventory_mode=True).sudo().create( + new_quantity = self.env['stock.quant'].with_context(inventory_mode=True).sudo().create( { 'product_id': product_id, 'location_id': location_id, 'inventory_quantity': self.pack_quantity, }) + new_quantity.action_apply_inventory() @api.onchange('pack_location_id') def change_quantity_based_on_location(self): diff --git a/product_combo_pack/views/product_form_views.xml b/product_combo_pack/views/product_form_views.xml index f8a572a49..7902029a0 100644 --- a/product_combo_pack/views/product_form_views.xml +++ b/product_combo_pack/views/product_form_views.xml @@ -47,7 +47,9 @@