From 079c298e6ca8d57ff88a5647b5681e987106589b Mon Sep 17 00:00:00 2001 From: Kobby Folson <51918015+kobfolson@users.noreply.github.com> Date: Thu, 22 Aug 2024 11:29:16 +0100 Subject: [PATCH] 17.0 mig sale force manual delivered (#16) * [17.0][MIG] sale_force_manual_delivered: Migration to 17.0 --------- Co-authored-by: GarethGloSystems Co-authored-by: Karl Co-authored-by: Kobby Folson --- sale_force_manual_delivered/README.rst | 5 +++ sale_force_manual_delivered/__init__.py | 1 + sale_force_manual_delivered/__manifest__.py | 13 ++++++++ .../models/__init__.py | 1 + .../models/sale_order.py | 17 ++++++++++ sale_force_manual_delivered/pyproject.toml | 3 ++ sale_force_manual_delivered/tests/__init__.py | 1 + .../tests/test_force_manual_delivered_qty.py | 32 +++++++++++++++++++ .../views/sale_order.xml | 20 ++++++++++++ 9 files changed, 93 insertions(+) create mode 100644 sale_force_manual_delivered/README.rst create mode 100644 sale_force_manual_delivered/__init__.py create mode 100644 sale_force_manual_delivered/__manifest__.py create mode 100644 sale_force_manual_delivered/models/__init__.py create mode 100644 sale_force_manual_delivered/models/sale_order.py create mode 100644 sale_force_manual_delivered/pyproject.toml create mode 100644 sale_force_manual_delivered/tests/__init__.py create mode 100644 sale_force_manual_delivered/tests/test_force_manual_delivered_qty.py create mode 100644 sale_force_manual_delivered/views/sale_order.xml diff --git a/sale_force_manual_delivered/README.rst b/sale_force_manual_delivered/README.rst new file mode 100644 index 0000000..8a1eae1 --- /dev/null +++ b/sale_force_manual_delivered/README.rst @@ -0,0 +1,5 @@ +sale_force_manual_delivered +--------------------------- + +Generalises force_manual_delivered_qty from TC's wwuk_sales_order + \ No newline at end of file diff --git a/sale_force_manual_delivered/__init__.py b/sale_force_manual_delivered/__init__.py new file mode 100644 index 0000000..0650744 --- /dev/null +++ b/sale_force_manual_delivered/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/sale_force_manual_delivered/__manifest__.py b/sale_force_manual_delivered/__manifest__.py new file mode 100644 index 0000000..ce6e91b --- /dev/null +++ b/sale_force_manual_delivered/__manifest__.py @@ -0,0 +1,13 @@ +{ + "name": "sale_forced_manual_delivered_qty", + "summary": "Allow forced manual delivery", + "author": "Glo Networks", + "website": "https://github.com/GlodoUK/sale", + "category": "Sales", + "version": "17.0.1.0.0", + "depends": ["sale_stock"], + "data": [ + "views/sale_order.xml", + ], + "license": "LGPL-3", +} diff --git a/sale_force_manual_delivered/models/__init__.py b/sale_force_manual_delivered/models/__init__.py new file mode 100644 index 0000000..6aacb75 --- /dev/null +++ b/sale_force_manual_delivered/models/__init__.py @@ -0,0 +1 @@ +from . import sale_order diff --git a/sale_force_manual_delivered/models/sale_order.py b/sale_force_manual_delivered/models/sale_order.py new file mode 100644 index 0000000..6993a2f --- /dev/null +++ b/sale_force_manual_delivered/models/sale_order.py @@ -0,0 +1,17 @@ +from odoo import api, fields, models + + +class SaleOrderLine(models.Model): + _inherit = "sale.order.line" + + force_manual_delivered_qty = fields.Boolean(default=False) + + @api.depends("force_manual_delivered_qty", "is_expense", "state") + def _compute_qty_delivered_method(self): + res = super()._compute_qty_delivered_method() + for line in self.filtered( + lambda order_line: order_line.force_manual_delivered_qty + ): + if line.force_manual_delivered_qty: + line.qty_delivered_method = "manual" + return res diff --git a/sale_force_manual_delivered/pyproject.toml b/sale_force_manual_delivered/pyproject.toml new file mode 100644 index 0000000..4231d0c --- /dev/null +++ b/sale_force_manual_delivered/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["whool"] +build-backend = "whool.buildapi" diff --git a/sale_force_manual_delivered/tests/__init__.py b/sale_force_manual_delivered/tests/__init__.py new file mode 100644 index 0000000..9190b93 --- /dev/null +++ b/sale_force_manual_delivered/tests/__init__.py @@ -0,0 +1 @@ +from . import test_force_manual_delivered_qty diff --git a/sale_force_manual_delivered/tests/test_force_manual_delivered_qty.py b/sale_force_manual_delivered/tests/test_force_manual_delivered_qty.py new file mode 100644 index 0000000..7f25345 --- /dev/null +++ b/sale_force_manual_delivered/tests/test_force_manual_delivered_qty.py @@ -0,0 +1,32 @@ +from odoo.tests import tagged +from odoo.tests.common import TransactionCase + + +@tagged("post_install", "-at_install") +class TestForceManualDeliveredQty(TransactionCase): + def setUp(self): + super().setUp() + + self.partner_id = self.env["res.partner"].create({"name": "Test Partner"}) + + self.product_id = self.env["product.product"].create({"name": "Product A"}) + + def test_force_manual_delivered_qty(self): + sale_order_id = self.env["sale.order"].create( + { + "partner_id": self.partner_id.id, + "order_line": [ + ( + 0, + 0, + { + "product_id": self.product_id.id, + "product_uom_qty": 1.0, + }, + ) + ], + } + ) + sale_order_id.order_line[0].force_manual_delivered_qty = True + + self.assertEqual(sale_order_id.order_line[0].qty_delivered_method, "manual") diff --git a/sale_force_manual_delivered/views/sale_order.xml b/sale_force_manual_delivered/views/sale_order.xml new file mode 100644 index 0000000..ab31951 --- /dev/null +++ b/sale_force_manual_delivered/views/sale_order.xml @@ -0,0 +1,20 @@ + + + + glodo_sale_view_order_form + sale.order + + + + + + + +