Debian Codegraph @

addons/delivery_stock_picking_batch/models/stock_picking_batch.py

raw
1 # -*- coding: utf-8 -*-
2 # Part of Odoo. See LICENSE file for full copyright and licensing details.
3
4 from odoo import models
5
6
7 class StockPickingBatch(models.Model):
8 _inherit = "stock.picking.batch"
9
10 def _is_picking_auto_mergeable(self, picking):
11 """ Verifies if a picking can be safely inserted into the batch without violating auto_batch_constrains.
12 """
13 res = super()._is_picking_auto_mergeable(picking)
14 if self.picking_type_id.batch_max_weight:
15 batch_weight = sum(self.picking_ids.mapped('weight'))
16 res = res and (batch_weight + picking.weight <= self.picking_type_id.batch_max_weight)
17 return res
18
19 def _is_line_auto_mergeable(self, num_of_moves=False, num_of_pickings=False, weight=False):
20 res = super()._is_line_auto_mergeable(num_of_moves, num_of_pickings, weight)
21 if self.picking_type_id.batch_max_weight:
22 wave_weight = sum(self.move_ids.mapped('weight'))
23 res = res and (wave_weight + weight <= self.picking_type_id.batch_max_weight)
24 return res