From 282ced1da3b1bd689e24583cfa383d1d9258be12 Mon Sep 17 00:00:00 2001 From: Christopher Ormaza Date: Mon, 14 Mar 2022 09:14:21 -0500 Subject: [PATCH 1/4] [14.0][ADD] rma_delivery --- rma_delivery/README.rst | 65 ++++ rma_delivery/__init__.py | 2 + rma_delivery/__manifest__.py | 21 ++ rma_delivery/models/__init__.py | 1 + rma_delivery/models/rma_operation.py | 13 + rma_delivery/readme/CONTRIBUTORS.rst | 1 + rma_delivery/readme/DESCRIPTION.rst | 1 + rma_delivery/static/description/index.html | 416 +++++++++++++++++++++ rma_delivery/tests/__init__.py | 1 + rma_delivery/tests/test_rma_delivery.py | 61 +++ rma_delivery/views/rma_operation_view.xml | 17 + rma_delivery/wizard/__init__.py | 1 + rma_delivery/wizard/rma_make_picking.py | 20 + 13 files changed, 620 insertions(+) create mode 100644 rma_delivery/README.rst create mode 100644 rma_delivery/__init__.py create mode 100644 rma_delivery/__manifest__.py create mode 100644 rma_delivery/models/__init__.py create mode 100644 rma_delivery/models/rma_operation.py create mode 100644 rma_delivery/readme/CONTRIBUTORS.rst create mode 100644 rma_delivery/readme/DESCRIPTION.rst create mode 100644 rma_delivery/static/description/index.html create mode 100644 rma_delivery/tests/__init__.py create mode 100644 rma_delivery/tests/test_rma_delivery.py create mode 100644 rma_delivery/views/rma_operation_view.xml create mode 100644 rma_delivery/wizard/__init__.py create mode 100644 rma_delivery/wizard/rma_make_picking.py diff --git a/rma_delivery/README.rst b/rma_delivery/README.rst new file mode 100644 index 000000000..c0f3cdf0a --- /dev/null +++ b/rma_delivery/README.rst @@ -0,0 +1,65 @@ +======================== +RMA delivery integration +======================== + +.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png + :target: https://odoo-community.org/page/development-status + :alt: Beta +.. |badge2| image:: https://img.shields.io/badge/licence-LGPL--3-blue.png + :target: http://www.gnu.org/licenses/lgpl-3.0-standalone.html + :alt: License: LGPL-3 +.. |badge3| image:: https://img.shields.io/badge/github-ForgeFlow%2Fstock--rma-lightgray.png?logo=github + :target: https://github.com/ForgeFlow/stock-rma/tree/14.0/rma_delivery + :alt: ForgeFlow/stock-rma + +|badge1| |badge2| |badge3| + +Added delivery carrier default on pickings created by rma outgoing pickings + +**Table of contents** + +.. contents:: + :local: + +Bug Tracker +=========== + +Bugs are tracked on `GitHub Issues `_. +In case of trouble, please check there if your issue has already been reported. +If you spotted it first, help us smashing it by providing a detailed and welcomed +`feedback `_. + +Do not contact contributors directly about support or help with technical issues. + +Credits +======= + +Authors +~~~~~~~ + +* ForgeFlow + +Contributors +~~~~~~~~~~~~ + +* Christopher Ormaza + +Maintainers +~~~~~~~~~~~ + +.. |maintainer-ChrisOForgeFlow| image:: https://github.com/ChrisOForgeFlow.png?size=40px + :target: https://github.com/ChrisOForgeFlow + :alt: ChrisOForgeFlow + +Current maintainer: + +|maintainer-ChrisOForgeFlow| + +This module is part of the `ForgeFlow/stock-rma `_ project on GitHub. + +You are welcome to contribute. diff --git a/rma_delivery/__init__.py b/rma_delivery/__init__.py new file mode 100644 index 000000000..9b4296142 --- /dev/null +++ b/rma_delivery/__init__.py @@ -0,0 +1,2 @@ +from . import models +from . import wizard diff --git a/rma_delivery/__manifest__.py b/rma_delivery/__manifest__.py new file mode 100644 index 000000000..481a1ce69 --- /dev/null +++ b/rma_delivery/__manifest__.py @@ -0,0 +1,21 @@ +# Copyright (C) 2022 ForgeFlow S.L. +# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html) + +{ + "name": "RMA delivery integration", + "version": "14.0.1.0.0", + "license": "LGPL-3", + "category": "RMA", + "summary": "RMA default carrier on operation" "in odoo", + "author": "ForgeFlow", + "website": "https://github.com/ForgeFlow/stock-rma", + "depends": ["rma", "delivery"], + "demo": [], + "data": [ + "views/rma_operation_view.xml", + ], + "installable": True, + "application": False, + "development_status": "Beta", + "maintainers": ["ChrisOForgeFlow"], +} diff --git a/rma_delivery/models/__init__.py b/rma_delivery/models/__init__.py new file mode 100644 index 000000000..9fd5ac20a --- /dev/null +++ b/rma_delivery/models/__init__.py @@ -0,0 +1 @@ +from . import rma_operation diff --git a/rma_delivery/models/rma_operation.py b/rma_delivery/models/rma_operation.py new file mode 100644 index 000000000..96fc71d72 --- /dev/null +++ b/rma_delivery/models/rma_operation.py @@ -0,0 +1,13 @@ +# Copyright (C) 2022 ForgeFlow S.L. +# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html) + +from odoo import fields, models + + +class RmaOperation(models.Model): + + _inherit = "rma.operation" + + default_carrier_id = fields.Many2one( + comodel_name="delivery.carrier", string="Default carrier", required=False + ) diff --git a/rma_delivery/readme/CONTRIBUTORS.rst b/rma_delivery/readme/CONTRIBUTORS.rst new file mode 100644 index 000000000..b647a292e --- /dev/null +++ b/rma_delivery/readme/CONTRIBUTORS.rst @@ -0,0 +1 @@ +* Christopher Ormaza diff --git a/rma_delivery/readme/DESCRIPTION.rst b/rma_delivery/readme/DESCRIPTION.rst new file mode 100644 index 000000000..8d85e834e --- /dev/null +++ b/rma_delivery/readme/DESCRIPTION.rst @@ -0,0 +1 @@ +Added delivery carrier default on pickings created by rma outgoing pickings diff --git a/rma_delivery/static/description/index.html b/rma_delivery/static/description/index.html new file mode 100644 index 000000000..153b3e99e --- /dev/null +++ b/rma_delivery/static/description/index.html @@ -0,0 +1,416 @@ + + + + + + +RMA delivery integration + + + +
+

RMA delivery integration

+ + +

Beta License: LGPL-3 ForgeFlow/stock-rma

+

Added delivery carrier default on pickings created by rma outgoing pickings

+

Table of contents

+ +
+

Bug Tracker

+

Bugs are tracked on GitHub Issues. +In case of trouble, please check there if your issue has already been reported. +If you spotted it first, help us smashing it by providing a detailed and welcomed +feedback.

+

Do not contact contributors directly about support or help with technical issues.

+
+
+

Credits

+
+

Authors

+
    +
  • ForgeFlow
  • +
+
+
+

Contributors

+ +
+
+

Maintainers

+

Current maintainer:

+

ChrisOForgeFlow

+

This module is part of the ForgeFlow/stock-rma project on GitHub.

+

You are welcome to contribute.

+
+
+
+ + diff --git a/rma_delivery/tests/__init__.py b/rma_delivery/tests/__init__.py new file mode 100644 index 000000000..d85e96764 --- /dev/null +++ b/rma_delivery/tests/__init__.py @@ -0,0 +1 @@ +from . import test_rma_delivery diff --git a/rma_delivery/tests/test_rma_delivery.py b/rma_delivery/tests/test_rma_delivery.py new file mode 100644 index 000000000..1ace3408b --- /dev/null +++ b/rma_delivery/tests/test_rma_delivery.py @@ -0,0 +1,61 @@ +# Copyright (C) 2022 ForgeFlow S.L. +# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html) + +from odoo.addons.rma.tests.test_rma import TestRma + + +class TestRmaDelivery(TestRma): + @classmethod + def setUpClass(cls): + super().setUpClass() + cls.product_delivery_normal = cls.env["product.product"].create( + { + "name": "Normal Delivery Charges", + "type": "service", + "list_price": 10.0, + "categ_id": cls.env.ref("delivery.product_category_deliveries").id, + } + ) + cls.carrier_id = cls.env["delivery.carrier"].create( + { + "name": "Test Carrier", + "fixed_price": 10, + "delivery_type": "fixed", + "product_id": cls.product_delivery_normal.id, + } + ) + cls.rma_cust_replace_op_id.write( + { + "default_carrier_id": cls.carrier_id.id, + } + ) + + def test_rma_delivery(self): + self.rma_customer_id.rma_line_ids.action_rma_to_approve() + wizard = self.rma_make_picking.with_context( + { + "active_ids": self.rma_customer_id.rma_line_ids.ids, + "active_model": "rma.order.line", + "picking_type": "incoming", + "active_id": self.rma_customer_id.rma_line_ids.ids[0], + } + ).create({}) + wizard._create_picking() + res = self.rma_customer_id.rma_line_ids.action_view_in_shipments() + picking = self.env["stock.picking"].browse(res["res_id"]) + picking.action_assign() + for mv in picking.move_lines: + mv.quantity_done = mv.product_uom_qty + picking._action_done() + wizard = self.rma_make_picking.with_context( + { + "active_id": self.rma_customer_id.rma_line_ids.ids[0], + "active_ids": self.rma_customer_id.rma_line_ids.ids, + "active_model": "rma.order.line", + "picking_type": "outgoing", + } + ).create({}) + wizard._create_picking() + res = self.rma_customer_id.rma_line_ids.action_view_out_shipments() + picking = self.env["stock.picking"].browse(res["res_id"]) + self.assertEqual(self.carrier_id.ids, picking.carrier_id.ids) diff --git a/rma_delivery/views/rma_operation_view.xml b/rma_delivery/views/rma_operation_view.xml new file mode 100644 index 000000000..2ff58f437 --- /dev/null +++ b/rma_delivery/views/rma_operation_view.xml @@ -0,0 +1,17 @@ + + + + + + rma.operation.form.view + rma.operation + + + + + + + + + + diff --git a/rma_delivery/wizard/__init__.py b/rma_delivery/wizard/__init__.py new file mode 100644 index 000000000..8a3b735f4 --- /dev/null +++ b/rma_delivery/wizard/__init__.py @@ -0,0 +1 @@ +from . import rma_make_picking diff --git a/rma_delivery/wizard/rma_make_picking.py b/rma_delivery/wizard/rma_make_picking.py new file mode 100644 index 000000000..9d74a05fe --- /dev/null +++ b/rma_delivery/wizard/rma_make_picking.py @@ -0,0 +1,20 @@ +# Copyright (C) 2022 ForgeFlow S.L. +# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html) + +from odoo import models + + +class RmaMakePicking(models.TransientModel): + + _inherit = "rma_make_picking.wizard" + + def _create_picking(self): + res = super()._create_picking() + for line in self.mapped("item_ids.line_id").filtered( + lambda x: x.operation_id.default_carrier_id + ): + pickings = line._get_out_pickings().filtered( + lambda x: x.location_dest_id.usage == "customer" and not x.carrier_id + ) + pickings.write({"carrier_id": line.operation_id.default_carrier_id.id}) + return res From 8dfb96387652ed5a8cd524dcccc1062cc4680e35 Mon Sep 17 00:00:00 2001 From: Christopher Ormaza Date: Mon, 14 Mar 2022 15:14:24 -0500 Subject: [PATCH 2/4] [FIX] allow write value on every picking on complex routes --- rma_delivery/wizard/rma_make_picking.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/rma_delivery/wizard/rma_make_picking.py b/rma_delivery/wizard/rma_make_picking.py index 9d74a05fe..78c0e5138 100644 --- a/rma_delivery/wizard/rma_make_picking.py +++ b/rma_delivery/wizard/rma_make_picking.py @@ -13,8 +13,6 @@ def _create_picking(self): for line in self.mapped("item_ids.line_id").filtered( lambda x: x.operation_id.default_carrier_id ): - pickings = line._get_out_pickings().filtered( - lambda x: x.location_dest_id.usage == "customer" and not x.carrier_id - ) + pickings = line._get_out_pickings().filtered(lambda x: not x.carrier_id) pickings.write({"carrier_id": line.operation_id.default_carrier_id.id}) return res From 82c35e956e040b2a13f3c00ca523599135c91be3 Mon Sep 17 00:00:00 2001 From: AlexPForgeFlow Date: Wed, 23 Aug 2023 16:02:54 +0200 Subject: [PATCH 3/4] [IMP] rma_delivery: pre-commit stuff --- setup/rma_delivery/odoo/addons/rma_delivery | 1 + setup/rma_delivery/setup.py | 6 ++++++ 2 files changed, 7 insertions(+) create mode 120000 setup/rma_delivery/odoo/addons/rma_delivery create mode 100644 setup/rma_delivery/setup.py diff --git a/setup/rma_delivery/odoo/addons/rma_delivery b/setup/rma_delivery/odoo/addons/rma_delivery new file mode 120000 index 000000000..93c206446 --- /dev/null +++ b/setup/rma_delivery/odoo/addons/rma_delivery @@ -0,0 +1 @@ +../../../../rma_delivery \ No newline at end of file diff --git a/setup/rma_delivery/setup.py b/setup/rma_delivery/setup.py new file mode 100644 index 000000000..28c57bb64 --- /dev/null +++ b/setup/rma_delivery/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +) From 5232eb160f89e76a160127afa824f910f9a09969 Mon Sep 17 00:00:00 2001 From: AlexPForgeFlow Date: Wed, 23 Aug 2023 16:45:13 +0200 Subject: [PATCH 4/4] [MIG] rma_delivery: Migration to 16.0 --- rma_delivery/__manifest__.py | 2 +- rma_delivery/tests/test_rma_delivery.py | 22 +++++++++------------ rma_delivery/views/rma_operation_view.xml | 24 ++++++++++------------- 3 files changed, 20 insertions(+), 28 deletions(-) diff --git a/rma_delivery/__manifest__.py b/rma_delivery/__manifest__.py index 481a1ce69..c7f9c39e1 100644 --- a/rma_delivery/__manifest__.py +++ b/rma_delivery/__manifest__.py @@ -3,7 +3,7 @@ { "name": "RMA delivery integration", - "version": "14.0.1.0.0", + "version": "16.0.1.0.0", "license": "LGPL-3", "category": "RMA", "summary": "RMA default carrier on operation" "in odoo", diff --git a/rma_delivery/tests/test_rma_delivery.py b/rma_delivery/tests/test_rma_delivery.py index 1ace3408b..adde465d2 100644 --- a/rma_delivery/tests/test_rma_delivery.py +++ b/rma_delivery/tests/test_rma_delivery.py @@ -33,27 +33,23 @@ def setUpClass(cls): def test_rma_delivery(self): self.rma_customer_id.rma_line_ids.action_rma_to_approve() wizard = self.rma_make_picking.with_context( - { - "active_ids": self.rma_customer_id.rma_line_ids.ids, - "active_model": "rma.order.line", - "picking_type": "incoming", - "active_id": self.rma_customer_id.rma_line_ids.ids[0], - } + active_ids=self.rma_customer_id.rma_line_ids.ids, + active_model="rma.order.line", + picking_type="incoming", + active_id=self.rma_customer_id.rma_line_ids.ids[0], ).create({}) wizard._create_picking() res = self.rma_customer_id.rma_line_ids.action_view_in_shipments() picking = self.env["stock.picking"].browse(res["res_id"]) picking.action_assign() - for mv in picking.move_lines: + for mv in picking.move_ids: mv.quantity_done = mv.product_uom_qty picking._action_done() wizard = self.rma_make_picking.with_context( - { - "active_id": self.rma_customer_id.rma_line_ids.ids[0], - "active_ids": self.rma_customer_id.rma_line_ids.ids, - "active_model": "rma.order.line", - "picking_type": "outgoing", - } + active_id=self.rma_customer_id.rma_line_ids.ids[0], + active_ids=self.rma_customer_id.rma_line_ids.ids, + active_model="rma.order.line", + picking_type="outgoing", ).create({}) wizard._create_picking() res = self.rma_customer_id.rma_line_ids.action_view_out_shipments() diff --git a/rma_delivery/views/rma_operation_view.xml b/rma_delivery/views/rma_operation_view.xml index 2ff58f437..5cb9c2e49 100644 --- a/rma_delivery/views/rma_operation_view.xml +++ b/rma_delivery/views/rma_operation_view.xml @@ -1,17 +1,13 @@ - - - - rma.operation.form.view - rma.operation - - - - - - - - - + + rma.operation.form.view + rma.operation + + + + + + +