addons-cm/stock_picking_batch_custom/models/stock_move_line.py
snt 5bb5d20244 [IMP] stock_picking_batch_custom: add home_delivery indicator to move line view
Add related field home_delivery on stock.move.line from picking_id,
and expose it in the batch move line list view as an optional boolean toggle.
2026-05-20 16:05:14 +02:00

44 lines
1.1 KiB
Python

# Copyright 2026 Criptomart
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo import api
from odoo import fields
from odoo import models
class StockMoveLine(models.Model):
_inherit = "stock.move.line"
product_categ_id = fields.Many2one(
comodel_name="product.category",
string="Product Category (Batch)",
related="product_id.categ_id",
store=True,
readonly=True,
)
is_collected = fields.Boolean(
string="Collected",
default=False,
copy=False,
)
home_delivery = fields.Boolean(
related="picking_id.home_delivery",
readonly=True,
)
consumer_group_id = fields.Many2one(
comodel_name="res.partner",
compute="_compute_consumer_group_id",
readonly=True,
)
@api.depends("picking_id")
def _compute_consumer_group_id(self):
for line in self:
picking = line.picking_id
if picking:
line.consumer_group_id = picking.batch_consumer_group_id
else:
line.consumer_group_id = False