diff --git a/purchase_return_picking_type/README.rst b/purchase_return_picking_type/README.rst new file mode 100644 index 00000000000..4120c5165ae --- /dev/null +++ b/purchase_return_picking_type/README.rst @@ -0,0 +1,83 @@ +============================ +Purchase Return Picking Type +============================ + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:4aaf8a2b6dedc23ab40ebf59403c611a8e55964c2b1ecb1e788453c546c6cd17 + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |badge1| image:: https://img.shields.io/badge/maturity-Alpha-red.png + :target: https://odoo-community.org/page/development-status + :alt: Alpha +.. |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-OCA%2Fpurchase--workflow-lightgray.png?logo=github + :target: https://github.com/OCA/purchase-workflow/tree/16.0/purchase_return_picking_type + :alt: OCA/purchase-workflow +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/purchase-workflow-16-0/purchase-workflow-16-0-purchase_return_picking_type + :alt: Translate me on Weblate +.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png + :target: https://runboat.odoo-community.org/builds?repo=OCA/purchase-workflow&target_branch=16.0 + :alt: Try me on Runboat + +|badge1| |badge2| |badge3| |badge4| |badge5| + +This module allows to define an Operation Type in Purchase Return Orders. + +.. IMPORTANT:: + This is an alpha version, the data model and design can change at any time without warning. + Only for development or testing purpose, do not use in production. + `More details on development status `_ + +**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 to smash it by providing a detailed and welcomed +`feedback `_. + +Do not contact contributors directly about support or help with technical issues. + +Credits +======= + +Authors +~~~~~~~ + +* ForgeFlow + +Contributors +~~~~~~~~~~~~ + +* ForgeFlow, S.L. + + * Alex Paris + +Maintainers +~~~~~~~~~~~ + +This module is maintained by the OCA. + +.. image:: https://odoo-community.org/logo.png + :alt: Odoo Community Association + :target: https://odoo-community.org + +OCA, or the Odoo Community Association, is a nonprofit organization whose +mission is to support the collaborative development of Odoo features and +promote its widespread use. + +This module is part of the `OCA/purchase-workflow `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/purchase_return_picking_type/__init__.py b/purchase_return_picking_type/__init__.py new file mode 100644 index 00000000000..0650744f6bc --- /dev/null +++ b/purchase_return_picking_type/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/purchase_return_picking_type/__manifest__.py b/purchase_return_picking_type/__manifest__.py new file mode 100644 index 00000000000..7cc1849db4d --- /dev/null +++ b/purchase_return_picking_type/__manifest__.py @@ -0,0 +1,18 @@ +# Copyright 2025 ForgeFlow, S.L. (https://www.forgeflow.com) +# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl). +{ + "name": "Purchase Return Picking Type", + "summary": "Manage return orders and operation types.", + "version": "16.0.1.0.0", + "category": "Purchases", + "website": "https://github.com/OCA/purchase-workflow", + "author": "ForgeFlow, Odoo Community Association (OCA)", + "license": "LGPL-3", + "application": False, + "installable": True, + "depends": ["purchase_return", "purchase_stock"], + "data": [ + "views/purchase_return_views.xml", + ], + "development_status": "Alpha", +} diff --git a/purchase_return_picking_type/models/__init__.py b/purchase_return_picking_type/models/__init__.py new file mode 100644 index 00000000000..5b7b1564672 --- /dev/null +++ b/purchase_return_picking_type/models/__init__.py @@ -0,0 +1 @@ +from . import purchase_return_order diff --git a/purchase_return_picking_type/models/purchase_return_order.py b/purchase_return_picking_type/models/purchase_return_order.py new file mode 100644 index 00000000000..57c2d979c5d --- /dev/null +++ b/purchase_return_picking_type/models/purchase_return_order.py @@ -0,0 +1,40 @@ +# Copyright 2025 ForgeFlow, S.L. (https://www.forgeflow.com) +# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl). + +from odoo import api, fields, models + +from odoo.addons.purchase_return.models.purchase_return_order import ( + PurchaseOrderReturn as PurchaseReturn, +) + + +class PurchaseOrderReturn(models.Model): + _inherit = "purchase.return.order" + + picking_type_id = fields.Many2one( + "stock.picking.type", + "Delivered To", + states=PurchaseReturn.READONLY_STATES, + required=True, + default=lambda self: self._default_picking_type(), + domain="['|', ('warehouse_id', '=', False), " + "('warehouse_id.company_id', '=', company_id)]", + help="This will determine operation type of incoming shipment", + ) + + @api.model + def _get_picking_type(self, company_id): + picking_type = self.env["stock.picking.type"].search( + [("code", "=", "incoming"), ("warehouse_id.company_id", "=", company_id)] + ) + if not picking_type: + picking_type = self.env["stock.picking.type"].search( + [("code", "=", "incoming"), ("warehouse_id", "=", False)] + ) + return picking_type[:1] + + @api.model + def _default_picking_type(self): + return self._get_picking_type( + self.env.context.get("company_id") or self.env.company.id + ) diff --git a/purchase_return_picking_type/readme/CONTRIBUTORS.rst b/purchase_return_picking_type/readme/CONTRIBUTORS.rst new file mode 100644 index 00000000000..5a7c67a3c64 --- /dev/null +++ b/purchase_return_picking_type/readme/CONTRIBUTORS.rst @@ -0,0 +1,3 @@ +* ForgeFlow, S.L. + + * Alex Paris diff --git a/purchase_return_picking_type/readme/DESCRIPTION.rst b/purchase_return_picking_type/readme/DESCRIPTION.rst new file mode 100644 index 00000000000..9ad2ff01cfc --- /dev/null +++ b/purchase_return_picking_type/readme/DESCRIPTION.rst @@ -0,0 +1 @@ +This module allows to define an Operation Type in Purchase Return Orders. diff --git a/purchase_return_picking_type/static/description/index.html b/purchase_return_picking_type/static/description/index.html new file mode 100644 index 00000000000..cc734791d4b --- /dev/null +++ b/purchase_return_picking_type/static/description/index.html @@ -0,0 +1,435 @@ + + + + + +Purchase Return Picking Type + + + +
+

Purchase Return Picking Type

+ + +

Alpha License: LGPL-3 OCA/purchase-workflow Translate me on Weblate Try me on Runboat

+

This module allows to define an Operation Type in Purchase Return Orders.

+
+

Important

+

This is an alpha version, the data model and design can change at any time without warning. +Only for development or testing purpose, do not use in production. +More details on development status

+
+

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 to smash 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

+

This module is maintained by the OCA.

+ +Odoo Community Association + +

OCA, or the Odoo Community Association, is a nonprofit organization whose +mission is to support the collaborative development of Odoo features and +promote its widespread use.

+

This module is part of the OCA/purchase-workflow project on GitHub.

+

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

+
+
+
+ + diff --git a/purchase_return_picking_type/tests/__init__.py b/purchase_return_picking_type/tests/__init__.py new file mode 100644 index 00000000000..561e4c20367 --- /dev/null +++ b/purchase_return_picking_type/tests/__init__.py @@ -0,0 +1,4 @@ +# Copyright 2025 ForgeFlow, S.L. (https://www.forgeflow.com) +# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl). + +from . import test_purchase_return_picking_type diff --git a/purchase_return_picking_type/tests/test_purchase_return_picking_type.py b/purchase_return_picking_type/tests/test_purchase_return_picking_type.py new file mode 100644 index 00000000000..e9c3e7afad4 --- /dev/null +++ b/purchase_return_picking_type/tests/test_purchase_return_picking_type.py @@ -0,0 +1,40 @@ +# Copyright 2025 ForgeFlow, S.L. (https://www.forgeflow.com) +# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl). + +from odoo.tests.common import Form, TransactionCase + + +class TestPurchaseReturnCompany(TransactionCase): + def setUp(self): + super().setUp() + self.company = self.env["res.company"].create({"name": "Test Company"}) + self.supplier = self.env["res.partner"].create({"name": "Supplier"}) + + # When creating WH, odoo will create default + # picking types for Receipts/Delivery Orders... + self.warehouse = self.env["stock.warehouse"].create( + { + "name": "Test Warehouse", + "code": "TWH", + "company_id": self.company.id, + } + ) + + def test_purchase_return_picking_type_from(self): + with Form( + self.env["purchase.return.order"].with_context(company_id=self.company.id) + ) as form: + form.partner_id = self.supplier + + purchase_return_order = form.save() + + self.assertEqual( + purchase_return_order.picking_type_id.code, + "incoming", + "Wrong value in picking type code", + ) + self.assertEqual( + purchase_return_order.picking_type_id.name, + "Receipts", + "Wrong picking_type_id", + ) diff --git a/purchase_return_picking_type/views/purchase_return_views.xml b/purchase_return_picking_type/views/purchase_return_views.xml new file mode 100644 index 00000000000..6f82acad5b4 --- /dev/null +++ b/purchase_return_picking_type/views/purchase_return_views.xml @@ -0,0 +1,12 @@ + + + + purchase.return.order + + + + + + + + diff --git a/setup/purchase_return_picking_type/odoo/addons/purchase_return_picking_type b/setup/purchase_return_picking_type/odoo/addons/purchase_return_picking_type new file mode 120000 index 00000000000..10e28a692a6 --- /dev/null +++ b/setup/purchase_return_picking_type/odoo/addons/purchase_return_picking_type @@ -0,0 +1 @@ +../../../../purchase_return_picking_type \ No newline at end of file diff --git a/setup/purchase_return_picking_type/setup.py b/setup/purchase_return_picking_type/setup.py new file mode 100644 index 00000000000..28c57bb6403 --- /dev/null +++ b/setup/purchase_return_picking_type/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +)