Hello everyone, how could I configure the capacity of a storage location based on volume in odoo 18?
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
- CRM
- e-Commerce
- Contabilidad
- Inventario
- PoS
- Project
- MRP
Se marcó esta pregunta
In Odoo 18, you can configure the capacity of a storage location based on volume by utilizing custom fields, rules, and automation. Odoo doesn’t have a built-in feature for setting location capacity by volume, but this can be achieved with some customization. Here's how to implement it step-by-step:
1. Add a Volume Field to Storage Locations
You can add a custom field for volume capacity and use Odoo’s automated actions or custom modules to manage it.
Using Studio (If Available):
- Go to Inventory > Configuration > Locations.
- Open Odoo Studio (if enabled).
- Add the following fields:
- Capacity Volume (m³):
- Field Name: x_volume_capacity
- Type: Float
- Label: Volume Capacity
- Current Volume Used (m³):
- Field Name: x_volume_used
- Type: Float
- Label: Volume Used
- Capacity Volume (m³):
- Save the changes.
Without Studio (Custom Module):
If Studio is unavailable, you can achieve this using a custom module. Here's an example:
pythonCopy codefrom odoo import models, fields, api class StockLocation(models.Model): _inherit = 'stock.location' volume_capacity = fields.Float(string="Capacity Volume (m³)", help="Maximum volume the location can hold.") volume_used = fields.Float(string="Current Volume Used (m³)", compute='_compute_volume_used', store=True) @api.depends('quant_ids') def _compute_volume_used(self): for location in self: location.volume_used = sum(location.quant_ids.mapped(lambda q: q.quantity * q.product_id.volume))
2. Set Product Volume
Odoo already supports volume on the product level:
- Go to Inventory > Products.
- Open a product form view.
- Under the Inventory tab, ensure the "Volume" field is filled in.
- This value represents the volume of a single unit of the product.
3. Automate Volume Calculation
Ensure the total volume of products in a location doesn’t exceed its capacity:
Using Automated Actions:
- Go to Settings > Technical > Automated Actions.
- Create a new automated action:
- Model: stock.quant
- Trigger: On Update or On Creation.
- Condition: Add a condition to check if the location's volume_used exceeds volume_capacity.
- Action: Prevent the transaction or notify the user.
pythonCopy codeif record.location_id.volume_capacity > 0 and record.location_id.volume_used > record.location_id.volume_capacity: raise Warning(f"Location {record.location_id.name} has exceeded its volume capacity!")
Using Custom Python Constraints:
You can enforce a constraint directly in the model:
pythonCopy codefrom odoo.exceptions import ValidationError class StockLocation(models.Model): _inherit = 'stock.location' @api.constrains('quant_ids') def _check_volume_capacity(self): for location in self: if location.volume_capacity > 0 and location.volume_used > location.volume_capacity: raise ValidationError(f"Location {location.name} has exceeded its volume capacity!")
4. Enhance Stock Operations
You can further improve the process:
- Restrict Transfers: Add validation during stock picking to ensure the volume added to a location doesn’t exceed its capacity. Example:
pythonCopy codeclass StockPicking(models.Model): _inherit = 'stock.picking' @api.constrains('move_line_ids') def _check_location_volume(self): for move_line in self.move_line_ids: location = move_line.location_dest_id if location.volume_capacity > 0 and (location.volume_used + move_line.product_id.volume * move_line.qty_done) > location.volume_capacity: raise ValidationError(f"Cannot move products. Location {location.name} will exceed its volume capacity.")
- Add Alerts: Use server actions or scheduled actions to alert warehouse managers if a location is close to its capacity.
5. Reporting and Dashboard
- Volume Utilization Report: Create a custom report using Odoo’s reporting tools to monitor locations’ volume utilization.
- Dashboard Widget: Add a widget showing the top locations nearing their capacity.
Final Notes
- User Training: Train warehouse staff on maintaining product volumes for accurate tracking.
- Testing: Before deploying, test the configuration in a development or staging environment.
Thanks Gracious, I was seeing that you can configure storage categories and have the option to add maximum weight, can't you add maximum volume there either? or in general for odoo 18 it does not have the maximum volume option?
n Odoo 18, maximum weight is a built-in feature for storage locations, but maximum volume is not a native option provided out-of-the-box. However, it is possible to extend Odoo to include the maximum volume functionality for storage locations using customizations. Here's an explanation and possible solutions:
1. Maximum Weight in Odoo
Odoo allows you to configure a maximum weight for storage locations, which helps ensure that no more products are assigned to a location than it can physically handle. This is available under:
Inventory > Configuration > Locations (in the warehouse module).
2. Maximum Volume in Odoo
Out-of-the-Box Support
As of Odoo 18, there is no default feature to configure or track maximum volume for storage locations.
Customization Possibilities
You can implement the maximum volume feature by adding a custom field to the location configuration and logic to validate the total volume of products stored.
3. Customization to Add Maximum Volume
Here’s how you can add the maximum volume option:
Step 1: Add a Maximum Volume Field
Extend the stock.location Model: Create a custom module to add a maximum_volume field to storage locations.
from odoo import models, fields, api
class StockLocation(models.Model):
_inherit = 'stock.location'
maximum_volume = fields.Float(string="Maximum Volume (m³)", help="Maximum volume allowed for this location.")
current_volume = fields.Float(string="Current Volume (m³)", compute="_compute_current_volume", store=True)
@api.depends('quant_ids')
def _compute_current_volume(self):
for location in self:
total_volume = sum(quant.product_id.volume * quant.quantity for quant in location.quant_ids)
location.current_volume = total_volume
Add the Field to the Location Form View: Extend the form view to show the new field.
<record id="view_location_form_inherit" model="ir.ui.view">
<field name="name">stock.location.form.inherit</field>
<field name="model">stock.location</field>
<field name="inherit_id" ref="stock.view_location_form" />
<field name="arch" type="xml">
<xpath expr="//group[@name='location_usage']" position="after">
<group string="Capacity">
<field name="maximum_volume" />
<field name="current_volume" readonly="1" />
</group>
</xpath>
</field>
</record>
Step 2: Add Validation for Maximum Volume
Check Volume Before Adding Stock: Override the method responsible for updating inventory (e.g., stock.move).
from odoo import models, exceptions
class StockMove(models.Model):
_inherit = 'stock.move'
def _action_done(self):
for move in self:
location = move.location_dest_id
if location.maximum_volume > 0:
new_volume = location.current_volume + (move.product_id.volume * move.quantity_done)
if new_volume > location.maximum_volume:
raise exceptions.ValidationError(
f"Exceeding maximum volume for location {location.name}. Allowed: {location.maximum_volume} m³."
)
return super(StockMove, self)._action_done()
Test the Logic:
Ensure the logic prevents stock operations when the volume exceeds the limit.
Test various scenarios, including transfers and inventory adjustments.
4. Benefits of Adding Maximum Volume
Prevents overloading storage locations by volume.
Provides more precise control over inventory.
Helps align with physical warehouse constraints for volume-based planning.
5. Alternative: Explore Third-Party Modules
If developing a custom solution isn’t viable, check the Odoo App Store for third-party modules that may offer this functionality.
Thanks for your response Gracious
¿Le interesa esta conversación? ¡Participe en ella!
Cree una cuenta para poder utilizar funciones exclusivas e interactuar con la comunidad.
InscribirsePublicaciones relacionadas | Respuestas | Vistas | Actividad | |
---|---|---|---|---|
|
1
jun 25
|
731 | ||
|
1
jun 25
|
772 | ||
Inventory app undone status
Resuelto
|
|
2
jun 25
|
1502 | |
|
1
may 25
|
1527 | ||
|
1
abr 25
|
1751 |