From 2d4263852d20b1125c6aa774cd39a3ad8a9d1b84 Mon Sep 17 00:00:00 2001 From: JordiMForgeFlow Date: Fri, 19 Jul 2024 13:10:07 +0200 Subject: [PATCH] [ADD] ddmrp_sale_dropshipping --- ddmrp_sale_dropshipping/README.rst | 85 ++++ ddmrp_sale_dropshipping/__init__.py | 1 + ddmrp_sale_dropshipping/__manifest__.py | 17 + ddmrp_sale_dropshipping/models/__init__.py | 1 + .../models/stock_buffer.py | 30 ++ .../readme/CONTRIBUTORS.rst | 1 + .../readme/DESCRIPTION.rst | 2 + .../static/description/icon.png | Bin 0 -> 2440 bytes .../static/description/index.html | 423 ++++++++++++++++++ ddmrp_sale_dropshipping/tests/__init__.py | 1 + .../tests/test_ddmrp_sale_dropshipping.py | 49 ++ .../odoo/addons/ddmrp_sale_dropshipping | 1 + setup/ddmrp_sale_dropshipping/setup.py | 6 + 13 files changed, 617 insertions(+) create mode 100644 ddmrp_sale_dropshipping/README.rst create mode 100644 ddmrp_sale_dropshipping/__init__.py create mode 100644 ddmrp_sale_dropshipping/__manifest__.py create mode 100644 ddmrp_sale_dropshipping/models/__init__.py create mode 100644 ddmrp_sale_dropshipping/models/stock_buffer.py create mode 100644 ddmrp_sale_dropshipping/readme/CONTRIBUTORS.rst create mode 100644 ddmrp_sale_dropshipping/readme/DESCRIPTION.rst create mode 100644 ddmrp_sale_dropshipping/static/description/icon.png create mode 100644 ddmrp_sale_dropshipping/static/description/index.html create mode 100644 ddmrp_sale_dropshipping/tests/__init__.py create mode 100644 ddmrp_sale_dropshipping/tests/test_ddmrp_sale_dropshipping.py create mode 120000 setup/ddmrp_sale_dropshipping/odoo/addons/ddmrp_sale_dropshipping create mode 100644 setup/ddmrp_sale_dropshipping/setup.py diff --git a/ddmrp_sale_dropshipping/README.rst b/ddmrp_sale_dropshipping/README.rst new file mode 100644 index 000000000..79015d219 --- /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-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%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..a735e68a0 --- /dev/null +++ b/ddmrp_sale_dropshipping/__manifest__.py @@ -0,0 +1,17 @@ +# Copyright 2024 ForgeFlow S.L. (https://www.forgeflow.com) +# License LGPL-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": "LGPL-3", + "installable": 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..0682dceac --- /dev/null +++ b/ddmrp_sale_dropshipping/models/stock_buffer.py @@ -0,0 +1,30 @@ +# Copyright 2024 ForgeFlow S.L. (https://www.forgeflow.com) +# License LGPL-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 0000000000000000000000000000000000000000..f95fc7269c40d169477766bae2f39ae6eccee046 GIT binary patch literal 2440 zcmb7G`9Bl>AK!*7=E@y0N{-xeN!q zEh&nRWNdC9Ifu!yk7J+hPx!tckJsz8up#Eyyq000RWgo779 z;spji#P=W027l!TVT`?t512nvz}N5c=Z9ku{uls29VIZ}>)3zd`AKE0qaW5gIt&{h z9E%3T$HyDqjEca72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Y@|N622Z0B8YJDxcWuVg89gMfw|t5m z6!rPx*YJg<6`0hg-KR&^6&*vT$K3z7?#xpd*}4e8Z@)BWyN$!7s=U_5;twt(L?%+j zLqo$$ivK>)vPmYAF2tQEs<@ZdV4|e7R%@y^znY~oJu`tlkgCx0re6Un1lnQr^?H0V zDn#8pY+CWe#J^^ErWCOtriHWeg2dwmu!lPbvEUID$g*5tmi)a}F{Q`1(>A%+? zpQ1R~vr$2(^-DvfQ06blL0PeIG_i|)f3Z?A#? z%j^rX8s^ea6eoP=%1LQZ`_*elg!1#Hr5uJ>8VawsP_7$P7{GA7;PJ8Y1RiVX@90e} z(J%(-Q_2;Enxf8WPI;hNRc&pfB0tDWoF<+%AG7t}BPq=<-p&T6U}9q5CK;Mn-AdSR zQ%jSfy%j4(OsEnZETLuR2O4!o#tjb`Vrepfpz~LKOpkziU!eH62WipvzM|-~c^$}| zgsrtnD1iWeh7DYq{q7{}imxuL!X#MrzM&EJZe`qCQpd3i;D>`kF){k)dBFTAm>MMoIcJ1)9m;tFZNMUvMda|2}=B4ZX@qJuOEd_$&pUm%f8TgS2ULTZhnz zmwJpFL0&x6O9q7sNRmmD1q6kA9Mu(n4)7|&pm8;+=9;;n_9X38j4}4ZhjlBK!m$1L z#u^h>Ho4S}PqGc%$)l!jPTJ-oXk%?di9*3ak&vV+y81go*MMnqlk>B=w+m~vFPYsr zSPR~Vfvo~@f_5R*OGoD)aK@X6KOKP zzduufBko|4yyk5>Bt9(tmbeN-0lJ)_!3`2#%OIanCjjbYYi84BXqUSlr5J;nos{yW zoB&tA5u8qNze%wBStX#g=5mkdaX8aKAi8n?g+OE=Tg?|e)v6STPG6Mci|{pf{}70B zb+q|}q9dCEf}yp5typ=1k4(aA`6)QOiSH*N#{~PpCj^ + + + + +Glue module for DDMRP Sale and Dropshipping + + + +
+

Glue module for DDMRP Sale and Dropshipping

+ + +

Beta License: LGPL-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..d7dcf3750 --- /dev/null +++ b/ddmrp_sale_dropshipping/tests/__init__.py @@ -0,0 +1 @@ +from . import test_ddmrp_sale 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..011a490af --- /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 LGPL-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, +)