From 92943193bc3d7f9c9effa1d71f848544e9610b07 Mon Sep 17 00:00:00 2001 From: khoivo1601 Date: Tue, 20 Jun 2023 21:54:28 +0700 Subject: [PATCH 1/3] [IMP] add button Create Shipping Label --- delivery_postlogistics/models/stock_picking.py | 6 ++++++ delivery_postlogistics/views/stock.xml | 10 ++++++++++ 2 files changed, 16 insertions(+) diff --git a/delivery_postlogistics/models/stock_picking.py b/delivery_postlogistics/models/stock_picking.py index e2f2223f30..cf62eeaa8b 100644 --- a/delivery_postlogistics/models/stock_picking.py +++ b/delivery_postlogistics/models/stock_picking.py @@ -236,3 +236,9 @@ def generate_postlogistics_shipping_labels(self, package_ids=None): """Add label generation for PostLogistics""" self.ensure_one() return self._generate_postlogistics_label(package_ids=package_ids) + + def action_generate_carrier_label(self): + self.ensure_one() + if not self.carrier_id: + raise exceptions.UserError(_("Please, set a carrier.")) + self.env["delivery.carrier"].postlogistics_send_shipping(self) diff --git a/delivery_postlogistics/views/stock.xml b/delivery_postlogistics/views/stock.xml index 33b0aca601..6ae207e2bb 100644 --- a/delivery_postlogistics/views/stock.xml +++ b/delivery_postlogistics/views/stock.xml @@ -6,6 +6,16 @@ stock.picking + + + Date: Tue, 11 Jul 2023 14:59:15 +0700 Subject: [PATCH 3/3] [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