From 8e09b121ab77a858ddd077fef4343333338f5b7d Mon Sep 17 00:00:00 2001 From: duongtq Date: Tue, 11 Jul 2023 14:59:15 +0700 Subject: [PATCH] [IMP] returns: use same carrier as the original picking by default --- delivery_postlogistics/__init__.py | 1 + delivery_postlogistics/wizard/__init__.py | 1 + .../wizard/stock_picking_return.py | 12 ++++++++++++ 3 files changed, 14 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..54f68961c1 100644 --- a/delivery_postlogistics/__init__.py +++ b/delivery_postlogistics/__init__.py @@ -1,2 +1,3 @@ from . import models from . import postlogistics +from . import wizard diff --git a/delivery_postlogistics/wizard/__init__.py b/delivery_postlogistics/wizard/__init__.py new file mode 100644 index 0000000000..ad0b47c23f --- /dev/null +++ b/delivery_postlogistics/wizard/__init__.py @@ -0,0 +1 @@ +from . import stock_picking_return diff --git a/delivery_postlogistics/wizard/stock_picking_return.py b/delivery_postlogistics/wizard/stock_picking_return.py new file mode 100644 index 0000000000..708b209d54 --- /dev/null +++ b/delivery_postlogistics/wizard/stock_picking_return.py @@ -0,0 +1,12 @@ +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