stock_usability: Add computed field is_dropship (needed to customize some reports)

This commit is contained in:
Alexis de Lattre
2023-08-28 11:07:02 +02:00
parent 993aab7d18
commit 6b5282994a
6 changed files with 55 additions and 9 deletions

View File

@@ -1,5 +1,6 @@
from . import stock_move
from . import stock_picking
from . import stock_picking_type
from . import stock_location_route
from . import stock_warehouse_orderpoint
from . import stock_quant

View File

@@ -3,9 +3,6 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo import fields, models, _
import logging
logger = logging.getLogger(__name__)
class StockPicking(models.Model):
@@ -24,9 +21,3 @@ class StockPicking(models.Model):
for pick in self:
pick.message_post(body=_("Picking <b>unreserved</b>."))
return res
class StockPickingType(models.Model):
_inherit = 'stock.picking.type'
name = fields.Char(translate=False)

View File

@@ -0,0 +1,27 @@
# Copyright 2014-2020 Akretion (http://www.akretion.com)
# @author Alexis de Lattre <alexis.delattre@akretion.com>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo import api, fields, models
class StockPickingType(models.Model):
_inherit = 'stock.picking.type'
name = fields.Char(translate=False)
is_dropship = fields.Boolean(compute="_compute_is_dropship", store=True)
@api.depends("code", "warehouse_id", "default_location_src_id", "default_location_dest_id")
def _compute_is_dropship(self):
supplier_loc_id = self.env.ref("stock.stock_location_suppliers").id
customer_loc_id = self.env.ref("stock.stock_location_customers").id
for picktype in self:
is_dropship = False
if (
picktype.code == 'incoming'
and not picktype.warehouse_id
and picktype.default_location_src_id.id == supplier_loc_id
and picktype.default_location_dest_id.id == customer_loc_id
):
is_dropship = True
picktype.is_dropship = is_dropship