Files
encoach_backend_new_v2/odoo/addons/uom/tests/test_uom.py
Yamen Ahmad 3e83d8d7d5 feat: add complete EnCoach backend — Odoo 19 + all addons
Includes:
- Odoo 19 framework (odoo/)
- 27 custom EnCoach addons (new_project/custom_addons/)
  - encoach_core, encoach_api, encoach_lms_api, encoach_adaptive_api
  - encoach_exam, encoach_taxonomy, encoach_adaptive, encoach_assignment
  - encoach_ai, encoach_ai_grading, encoach_ai_generation, encoach_ai_media
  - encoach_courseware, encoach_communication, encoach_subscription
  - encoach_notification, encoach_approval, encoach_branding
  - encoach_classroom, encoach_registration, encoach_stats
  - encoach_faq, encoach_ticket, encoach_training, encoach_resources
  - encoach_adaptive_ai, encoach_sis
- 21 OpenEduCat Enterprise modules (new_project/enterprise-19/)
- 14 OpenEduCat Community modules (new_project/openeducat_erp-19.0/)
- Configuration: odoo.conf, requirements.txt, scripts
- 200+ REST API endpoints with JWT authentication
- SRS and test documentation

Made-with: Cursor
2026-04-01 17:10:04 +04:00

51 lines
2.2 KiB
Python

# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from odoo.addons.uom.tests.common import UomCommon
class TestUom(UomCommon):
def test_10_conversion(self):
qty = self.uom_gram._compute_quantity(1020000, self.uom_ton)
self.assertEqual(qty, 1.02, "Converted quantity does not correspond.")
price = self.uom_gram._compute_price(2, self.uom_ton)
self.assertEqual(price, 2000000.0, "Converted price does not correspond.")
# If the conversion factor for Dozens (1/12) is not stored with sufficient precision,
# the conversion of 1 Dozen into Units will give e.g. 12.00000000000047 Units
# and the Unit rounding will round that up to 13.
# This is a partial regression test for rev. 311c77bb, which is further improved
# by rev. fa2f7b86.
qty = self.uom_dozen._compute_quantity(1, self.uom_unit)
self.assertEqual(qty, 12.0, "Converted quantity does not correspond.")
# Regression test for side-effect of commit 311c77bb - converting 1234 Grams
# into Kilograms should work even if grams are rounded to 1.
qty = self.uom_gram._compute_quantity(1234, self.uom_kgm)
self.assertEqual(qty, 1.24, "Converted quantity does not correspond.")
def test_20_rounding(self):
product_uom = self.env['uom.uom'].create({
'name': 'Score',
'relative_factor': 20,
'relative_uom_id': self.uom_unit.id,
})
self.env['decimal.precision'].search([('name', '=', 'Product Unit')]).digits = 0
qty = self.uom_unit._compute_quantity(2, product_uom)
self.assertEqual(qty, 1, "Converted quantity should be rounded up.")
def test_30_quantity(self):
""" _check_qty rounds the available quantity of a product. To prevent rounding issue,
there should be no rounding if the product uom is the same as the package uom.
"""
uom = self.uom_unit
quantity = 22.43
rounding_method = 'DOWN'
result = self.uom_unit._check_qty(quantity, uom, rounding_method)
self.assertEqual(result, quantity, 'Quantity should not be rounded.')