mirror of
https://github.com/OCA/stock-logistics-warehouse.git
synced 2025-01-21 14:27:28 +02:00
29 lines
872 B
Python
29 lines
872 B
Python
# Copyright 2023 ACSONE SA/NV
|
|
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
|
|
|
|
from odoo import api, fields, models
|
|
|
|
|
|
class StockPicking(models.Model):
|
|
|
|
_inherit = "stock.picking"
|
|
|
|
volume = fields.Float(
|
|
compute="_compute_volume", readonly=False, store=True, compute_sudo=True
|
|
)
|
|
volume_uom_name = fields.Char(
|
|
string="Volume unit of measure label", compute="_compute_volume_uom_name"
|
|
)
|
|
|
|
@api.depends("move_ids", "move_ids.volume")
|
|
def _compute_volume(self):
|
|
for picking in self:
|
|
new_volume = sum(picking.move_ids.mapped("volume"))
|
|
if picking.volume != new_volume:
|
|
picking.volume = new_volume
|
|
|
|
def _compute_volume_uom_name(self):
|
|
self.volume_uom_name = self.env[
|
|
"product.template"
|
|
]._get_volume_uom_name_from_ir_config_parameter()
|