Skip to content

Commit

Permalink
[ADD] Addon: sale_order_total_quantity
Browse files Browse the repository at this point in the history
  • Loading branch information
Tiago370 committed Dec 30, 2024
1 parent eaee63b commit 09f5e84
Show file tree
Hide file tree
Showing 8 changed files with 97 additions and 0 deletions.
32 changes: 32 additions & 0 deletions sale_order_total_quantity/README.rst
Original file line number Diff line number Diff line change
@@ -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
===========

...
1 change: 1 addition & 0 deletions sale_order_total_quantity/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
18 changes: 18 additions & 0 deletions sale_order_total_quantity/__manifest__.py
Original file line number Diff line number Diff line change
@@ -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": [],
}
1 change: 1 addition & 0 deletions sale_order_total_quantity/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import sale_order
21 changes: 21 additions & 0 deletions sale_order_total_quantity/models/sale_order.py
Original file line number Diff line number Diff line change
@@ -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
17 changes: 17 additions & 0 deletions sale_order_total_quantity/views/sale_order.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="utf-8" ?>
<!-- Copyright 2024 KMEE
License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). -->
<odoo>

<record model="ir.ui.view" id="view_order_agent_form_inherit">
<field name="model">sale.order</field>
<field name="name">sale.agent.order.inherit.form</field>
<field name="inherit_id" ref="sale.view_order_form" />
<field name="arch" type="xml">
<field name="tax_totals_json" position="before">
<field name="total_units" />
</field>
</field>
</record>

</odoo>
6 changes: 6 additions & 0 deletions setup/sale_order_total_quantity/setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import setuptools

setuptools.setup(
setup_requires=['setuptools-odoo'],
odoo_addon=True,
)

0 comments on commit 09f5e84

Please sign in to comment.