stock_usability: Add computed field is_dropship (needed to customize some reports)
Add optional fields in stock.move tree view
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
from . import stock_move
|
||||
from . import stock_move_line
|
||||
from . import stock_picking
|
||||
from . import stock_picking_type
|
||||
from . import stock_warehouse_orderpoint
|
||||
from . import stock_quant
|
||||
from . import procurement_group
|
||||
|
||||
26
stock_usability/models/stock_picking_type.py
Normal file
26
stock_usability/models/stock_picking_type.py
Normal file
@@ -0,0 +1,26 @@
|
||||
# Copyright 2023 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'
|
||||
|
||||
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
|
||||
Reference in New Issue
Block a user