diff --git a/ddmrp_sale_dropshipping/README.rst b/ddmrp_sale_dropshipping/README.rst new file mode 100644 index 000000000..f203169e5 --- /dev/null +++ b/ddmrp_sale_dropshipping/README.rst @@ -0,0 +1,85 @@ +=========================================== +Glue module for DDMRP Sale and Dropshipping +=========================================== + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:05606a23107fc9942e6f78999b38eac4b219ddc706d2963334f2b222e81e7f86 + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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-AGPL--3-blue.png + :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html + :alt: License: AGPL-3 +.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fddmrp-lightgray.png?logo=github + :target: https://github.com/OCA/ddmrp/tree/16.0/ddmrp_sale_dropshipping + :alt: OCA/ddmrp +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/ddmrp-16-0/ddmrp-16-0-ddmrp_sale_dropshipping + :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/ddmrp&target_branch=16.0 + :alt: Try me on Runboat + +|badge1| |badge2| |badge3| |badge4| |badge5| + +Ignore qualified demand of sales quotations for buffered products that will be +dropshipped by forcing the route in the sale line. + +**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 +~~~~~~~~~~~~ + +* Jordi Masvidal + +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. + +.. |maintainer-JordiMForgeFlow| image:: https://github.com/JordiMForgeFlow.png?size=40px + :target: https://github.com/JordiMForgeFlow + :alt: JordiMForgeFlow + +Current `maintainer `__: + +|maintainer-JordiMForgeFlow| + +This module is part of the `OCA/ddmrp `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/ddmrp_sale_dropshipping/__init__.py b/ddmrp_sale_dropshipping/__init__.py new file mode 100644 index 000000000..0650744f6 --- /dev/null +++ b/ddmrp_sale_dropshipping/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/ddmrp_sale_dropshipping/__manifest__.py b/ddmrp_sale_dropshipping/__manifest__.py new file mode 100644 index 000000000..b319648ec --- /dev/null +++ b/ddmrp_sale_dropshipping/__manifest__.py @@ -0,0 +1,18 @@ +# Copyright 2024 ForgeFlow S.L. (https://www.forgeflow.com) +# License AGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). + +{ + "name": "Glue module for DDMRP Sale and Dropshipping", + "summary": "Ignore qualified demand of sale quotes that are dropshipped.", + "version": "16.0.1.0.0", + "development_status": "Beta", + "author": "ForgeFlow, Odoo Community Association (OCA)", + "maintainers": ["JordiMForgeFlow"], + "website": "https://github.com/OCA/ddmrp", + "category": "Warehouse Management", + "depends": ["ddmrp_sale", "stock_dropshipping"], + "data": [], + "license": "AGPL-3", + "installable": True, + "auto_install": True, +} diff --git a/ddmrp_sale_dropshipping/models/__init__.py b/ddmrp_sale_dropshipping/models/__init__.py new file mode 100644 index 000000000..46f971b6d --- /dev/null +++ b/ddmrp_sale_dropshipping/models/__init__.py @@ -0,0 +1 @@ +from . import stock_buffer diff --git a/ddmrp_sale_dropshipping/models/stock_buffer.py b/ddmrp_sale_dropshipping/models/stock_buffer.py new file mode 100644 index 000000000..897a4e078 --- /dev/null +++ b/ddmrp_sale_dropshipping/models/stock_buffer.py @@ -0,0 +1,30 @@ +# Copyright 2024 ForgeFlow S.L. (https://www.forgeflow.com) +# License AGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). + +from odoo import models + + +class StockBuffer(models.Model): + _inherit = "stock.buffer" + + def _search_sales_qualified_demand_domain(self): + res = super()._search_sales_qualified_demand_domain() + dropship_pick_types = self.env["stock.picking.type"].search( + [ + ("default_location_src_id.usage", "=", "supplier"), + ("default_location_dest_id.usage", "=", "customer"), + ("company_id", "=", self.company_id.id), + ] + ) + dropship_routes = ( + self.env["stock.rule"] + .search([("picking_type_id", "in", dropship_pick_types.ids)]) + .mapped("route_id") + ) + if dropship_routes: + res += [ + "|", + ("route_id", "=", False), + ("route_id", "not in", dropship_routes.ids), + ] + return res diff --git a/ddmrp_sale_dropshipping/readme/CONTRIBUTORS.rst b/ddmrp_sale_dropshipping/readme/CONTRIBUTORS.rst new file mode 100644 index 000000000..e4263e418 --- /dev/null +++ b/ddmrp_sale_dropshipping/readme/CONTRIBUTORS.rst @@ -0,0 +1 @@ +* Jordi Masvidal diff --git a/ddmrp_sale_dropshipping/readme/DESCRIPTION.rst b/ddmrp_sale_dropshipping/readme/DESCRIPTION.rst new file mode 100644 index 000000000..8214fcb3e --- /dev/null +++ b/ddmrp_sale_dropshipping/readme/DESCRIPTION.rst @@ -0,0 +1,2 @@ +Ignore qualified demand of sales quotations for buffered products that will be +dropshipped by forcing the route in the sale line. diff --git a/ddmrp_sale_dropshipping/static/description/icon.png b/ddmrp_sale_dropshipping/static/description/icon.png new file mode 100644 index 000000000..f95fc7269 Binary files /dev/null and b/ddmrp_sale_dropshipping/static/description/icon.png differ diff --git a/ddmrp_sale_dropshipping/static/description/index.html b/ddmrp_sale_dropshipping/static/description/index.html new file mode 100644 index 000000000..591d3673a --- /dev/null +++ b/ddmrp_sale_dropshipping/static/description/index.html @@ -0,0 +1,423 @@ + + + + + +Glue module for DDMRP Sale and Dropshipping + + + +
+

Glue module for DDMRP Sale and Dropshipping

+ + +

Beta License: AGPL-3 OCA/ddmrp Translate me on Weblate Try me on Runboat

+

Ignore qualified demand of sales quotations for buffered products that will be +dropshipped by forcing the route in the sale line.

+

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.

+

Current maintainer:

+

JordiMForgeFlow

+

This module is part of the OCA/ddmrp project on GitHub.

+

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

+
+
+
+ + diff --git a/ddmrp_sale_dropshipping/tests/__init__.py b/ddmrp_sale_dropshipping/tests/__init__.py new file mode 100644 index 000000000..a6e36f411 --- /dev/null +++ b/ddmrp_sale_dropshipping/tests/__init__.py @@ -0,0 +1 @@ +from . import test_ddmrp_sale_dropshipping diff --git a/ddmrp_sale_dropshipping/tests/test_ddmrp_sale_dropshipping.py b/ddmrp_sale_dropshipping/tests/test_ddmrp_sale_dropshipping.py new file mode 100644 index 000000000..b88ececb1 --- /dev/null +++ b/ddmrp_sale_dropshipping/tests/test_ddmrp_sale_dropshipping.py @@ -0,0 +1,49 @@ +# Copyright 2024 ForgeFlow S.L. (https://www.forgeflow.com) +# License AGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). + +from datetime import datetime as dt, timedelta as td + +from odoo.addons.ddmrp_sale.tests.test_ddmrp_sale import TestDDMRPSale + + +class TestDDMRPSaleDropshipping(TestDDMRPSale): + @classmethod + def setUpClass(cls): + super().setUpClass() + + def test_01_dropship_quotation_not_included_as_demand(self): + self._refresh_involved_buffers() + self.assertEqual( + self.buffer_a.qualified_demand, self.buffer_internal.qualified_demand + ) + so_date = dt.today() + td(days=2) + so = self.so_model.create( + { + "partner_id": self.customer.id, + "partner_invoice_id": self.customer.id, + "partner_shipping_id": self.customer.id, + "commitment_date": so_date, + "order_line": [ + ( + 0, + 0, + { + "product_id": self.productA.id, + "name": "cool product", + "price_unit": 100.0, + "product_uom_qty": 17, # it is a spike. + "commitment_date": so_date, + "route_id": self.env.ref( + "stock_dropshipping.route_drop_shipping" + ).id, + }, + ) + ], + } + ) + self.assertEqual(so.state, "draft") + self._refresh_involved_buffers() + # Qualified demand ignored as the line route does not affect the buffer + # location + self.assertEqual(self.buffer_a.qualified_demand, 0) + self.assertEqual(self.buffer_internal.qualified_demand, 0) diff --git a/setup/ddmrp_sale_dropshipping/odoo/addons/ddmrp_sale_dropshipping b/setup/ddmrp_sale_dropshipping/odoo/addons/ddmrp_sale_dropshipping new file mode 120000 index 000000000..280c06961 --- /dev/null +++ b/setup/ddmrp_sale_dropshipping/odoo/addons/ddmrp_sale_dropshipping @@ -0,0 +1 @@ +../../../../ddmrp_sale_dropshipping \ No newline at end of file diff --git a/setup/ddmrp_sale_dropshipping/setup.py b/setup/ddmrp_sale_dropshipping/setup.py new file mode 100644 index 000000000..28c57bb64 --- /dev/null +++ b/setup/ddmrp_sale_dropshipping/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +)