From 2070e89ebae5663a25a6cc5d7d6bcc93627b5b4f Mon Sep 17 00:00:00 2001 From: duongtq Date: Tue, 11 Jul 2023 14:27:40 +0700 Subject: [PATCH] [IMP] set default carrier for return base on OUTs --- delivery_postlogistics/__init__.py | 1 + delivery_postlogistics/wizard/__init__.py | 0 delivery_postlogistics/wizard/stock_picking_return.py | 11 +++++++++++ 3 files changed, 12 insertions(+) create mode 100644 delivery_postlogistics/wizard/__init__.py create mode 100644 delivery_postlogistics/wizard/stock_picking_return.py diff --git a/delivery_postlogistics/__init__.py b/delivery_postlogistics/__init__.py index e4a5777ced..4439ed1d43 100644 --- a/delivery_postlogistics/__init__.py +++ b/delivery_postlogistics/__init__.py @@ -1,2 +1,3 @@ from . import models from . import postlogistics +from . import wizard \ No newline at end of file diff --git a/delivery_postlogistics/wizard/__init__.py b/delivery_postlogistics/wizard/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/delivery_postlogistics/wizard/stock_picking_return.py b/delivery_postlogistics/wizard/stock_picking_return.py new file mode 100644 index 0000000000..29843a44c0 --- /dev/null +++ b/delivery_postlogistics/wizard/stock_picking_return.py @@ -0,0 +1,11 @@ +from odoo import models + +class ReturnPicking(models.TransientModel): + _inherit = "stock.return.picking" + + def _create_returns(self): + new_picking, pick_type_id = super(ReturnPicking, self)._create_returns() + if self.picking_id.delivery_type == "postlogistics": + picking = self.env['stock.picking'].browse(new_picking) + picking.write({"carrier_id": self.picking_id.carrier_id.id}) + return new_picking, pick_type_id \ No newline at end of file