Files
encoach_backend_new_v2/odoo/addons/mrp/tests/test_quant.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

56 lines
2.0 KiB
Python

from odoo import Command
from odoo.exceptions import UserError
from odoo.addons.mrp.tests.common import TestMrpCommon
class TestMrpQuant(TestMrpCommon):
def test_kit_product_reservation_flow(self):
"""Test that kit products are not cleaned"""
product_kit = self.env['product.product'].create({
'name': 'This product will be a kit',
'type': 'consu',
'is_storable': True
})
delivery = self.env['stock.picking'].create({
'location_id': self.shelf_1.id,
'location_dest_id': self.warehouse_1.lot_stock_id.id,
'picking_type_id': self.picking_type_out.id,
'move_line_ids': [Command.create({
'product_id': product_kit.id,
'quantity_product_uom': 1,
'location_dest_id': self.warehouse_1.lot_stock_id.id,
})]
})
delivery.action_confirm()
self.env['mrp.bom'].create({
'product_tmpl_id': product_kit.product_tmpl_id.id,
'product_id': product_kit.id,
'product_qty': 1,
'type': 'phantom', # type kit
})
# Force recomputation of is_kits, since it's currently not recomputed automatically when BOM is created
product_kit._compute_is_kits()
delivery.move_ids.quantity = 1
product_normal = self.env['product.product'].create({
'name': 'Normal Product Test',
'type': 'consu',
'is_storable': True
})
# Should work without error
product_normal.action_open_quants()
# Ensure it's raise an error if we try to update quantity of kit product directly
with self.assertRaises(UserError, msg="You should update the components quantity instead of directly updating the quantity of the kit product."):
self.env['stock.quant']._update_available_quantity(
product_kit,
self.warehouse_1.lot_stock_id,
10,
)