diff --git a/stock_usability/models/__init__.py b/stock_usability/models/__init__.py index 04d9e97..26ba44b 100644 --- a/stock_usability/models/__init__.py +++ b/stock_usability/models/__init__.py @@ -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 diff --git a/stock_usability/models/stock_picking_type.py b/stock_usability/models/stock_picking_type.py new file mode 100644 index 0000000..adee65d --- /dev/null +++ b/stock_usability/models/stock_picking_type.py @@ -0,0 +1,26 @@ +# Copyright 2023 Akretion (http://www.akretion.com) +# @author Alexis de Lattre +# 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 diff --git a/stock_usability/views/stock_move.xml b/stock_usability/views/stock_move.xml index b59dd52..600bb9d 100644 --- a/stock_usability/views/stock_move.xml +++ b/stock_usability/views/stock_move.xml @@ -56,6 +56,10 @@ + + + + diff --git a/stock_usability/views/stock_picking_type.xml b/stock_usability/views/stock_picking_type.xml index f1fcbb4..55dbccd 100644 --- a/stock_usability/views/stock_picking_type.xml +++ b/stock_usability/views/stock_picking_type.xml @@ -1,12 +1,23 @@ + + stock.picking.type + + + + + + + + + usability.stock.picking.type.tree stock.picking.type