diff --git a/sale_order_total_quantity/README.rst b/sale_order_total_quantity/README.rst new file mode 100644 index 0000000..69bcec3 --- /dev/null +++ b/sale_order_total_quantity/README.rst @@ -0,0 +1,32 @@ +========================= +Sale Order Total Quantity +========================= + +KMEE + +Purpose +======= + +This module does this and that... + +Explain the use case. + +Configuration +============= + +To configure this module, you need to: + +#. Go to ... + +Usage +===== + +To use this module, you need to: + +#. Go to ... + + +How to test +=========== + +... diff --git a/sale_order_total_quantity/__init__.py b/sale_order_total_quantity/__init__.py new file mode 100644 index 0000000..0650744 --- /dev/null +++ b/sale_order_total_quantity/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/sale_order_total_quantity/__manifest__.py b/sale_order_total_quantity/__manifest__.py new file mode 100644 index 0000000..f449dd8 --- /dev/null +++ b/sale_order_total_quantity/__manifest__.py @@ -0,0 +1,18 @@ +# Copyright 2024 KMEE +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +{ + "name": "Sale Order Total Quantity", + "summary": """KMEE""", + "version": "15.0.1.0.0", + "license": "AGPL-3", + "author": "KMEE", + "website": "https://github.com/KMEE/kmee-odoo-addons", + "depends": [ + "sale", + ], + "data": [ + "views/sale_order.xml", + ], + "demo": [], +} diff --git a/sale_order_total_quantity/models/__init__.py b/sale_order_total_quantity/models/__init__.py new file mode 100644 index 0000000..6aacb75 --- /dev/null +++ b/sale_order_total_quantity/models/__init__.py @@ -0,0 +1 @@ +from . import sale_order diff --git a/sale_order_total_quantity/models/sale_order.py b/sale_order_total_quantity/models/sale_order.py new file mode 100644 index 0000000..edd07fb --- /dev/null +++ b/sale_order_total_quantity/models/sale_order.py @@ -0,0 +1,21 @@ +# Copyright 2024 KMEE +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from odoo import api, fields, models + + +class SaleOrder(models.Model): + + _inherit = "sale.order" + + total_units = fields.Integer( + compute="_compute_total_units", string="Total Units", store=True + ) + + @api.depends("order_line.product_uom_qty") + def _compute_total_units(self): + for order in self: + total_units = 0 + for line in order.order_line: + total_units += line.product_uom_qty + order.total_units = total_units diff --git a/sale_order_total_quantity/views/sale_order.xml b/sale_order_total_quantity/views/sale_order.xml new file mode 100644 index 0000000..19c7c9f --- /dev/null +++ b/sale_order_total_quantity/views/sale_order.xml @@ -0,0 +1,17 @@ + + + + + + sale.order + sale.agent.order.inherit.form + + + + + + + + + diff --git a/setup/sale_order_total_quantity/odoo/addons/sale_order_total_quantity b/setup/sale_order_total_quantity/odoo/addons/sale_order_total_quantity new file mode 120000 index 0000000..aa6c0d0 --- /dev/null +++ b/setup/sale_order_total_quantity/odoo/addons/sale_order_total_quantity @@ -0,0 +1 @@ +../../../../sale_order_total_quantity \ No newline at end of file diff --git a/setup/sale_order_total_quantity/setup.py b/setup/sale_order_total_quantity/setup.py new file mode 100644 index 0000000..28c57bb --- /dev/null +++ b/setup/sale_order_total_quantity/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +)