Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[15.0][ADD] Addon: sale_order_total_quantity #90

Merged
merged 1 commit into from
Jan 3, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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": "LGPL-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
19 changes: 19 additions & 0 deletions sale_order_total_quantity/models/sale_order.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# 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", 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="after">
<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,
)
Loading