Files
Odoo-Modules/fusion_plating/fusion_plating/tests/test_rack_load.py
gsinghpal a19a299c7f feat(fusion_plating): Office User grants Contact Creation + rack-load Phase 1 models
- group_fp_office_user now implies base.group_partner_manager so every office/
  manager role can create contacts (Technicians excluded). Fixes the live
  "create a company contact, it doesn't show" report (AccessError on save).
- New fp.rack.load + fp.rack.load.line models (multi-rack split at Racking,
  Phase 1) with sequence, ACLs, equal-split math, and tests.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-03 08:36:27 -04:00

28 lines
1.2 KiB
Python

# -*- coding: utf-8 -*-
# Phase 1 — rack-load core model tests.
from odoo.tests import TransactionCase, tagged
@tagged('post_install', '-at_install')
class TestRackLoad(TransactionCase):
def test_equal_split_math(self):
"""Remainder goes to the first racks (spec D4)."""
Load = self.env['fp.rack.load']
self.assertEqual(Load._fp_equal_split(100, 1), [100])
self.assertEqual(Load._fp_equal_split(100, 2), [50, 50])
self.assertEqual(Load._fp_equal_split(100, 3), [34, 33, 33])
self.assertEqual(Load._fp_equal_split(100, 4), [25, 25, 25, 25])
self.assertEqual(Load._fp_equal_split(10, 3), [4, 3, 3])
self.assertEqual(Load._fp_equal_split(0, 3), [0, 0, 0])
self.assertEqual(Load._fp_equal_split(5, 0), [])
# sums always equal the total
self.assertEqual(sum(Load._fp_equal_split(97, 6)), 97)
def test_create_sequence_and_qty_total(self):
rack = self.env['fusion.plating.rack'].create({'name': 'RL-TEST-RACK'})
load = self.env['fp.rack.load'].create({'rack_id': rack.id})
self.assertTrue(load.name.startswith('RACKLOAD/'))
self.assertEqual(load.state, 'loading')
self.assertEqual(load.qty_total, 0)