Sale (1177→2321 LOC): - Quotation templates (apply to order, option lines) - Sales reports (by month, product, customer, salesperson, category) - Advance payment wizard (delivered/percentage/fixed modes) - SO cancel wizard, discount wizard - action_quotation_sent, action_lock/unlock, preview_quotation - Line computes: invoice_status, price_reduce, untaxed_amount - Partner extension: sale_order_total Purchase (478→1424 LOC): - Purchase reports (by month, category, bill status, receipt analysis) - Receipt creation from PO (action_create_picking) - 3-way matching: action_view_picking, action_view_invoice - button_approve, button_done, action_rfq_send - Line computes: price_subtotal/total with tax, product onchange - Partner extension: purchase_order_count/total Project (218→1161 LOC): - Project updates (status tracking: on_track/at_risk/off_track) - Milestones (deadline, reached tracking, task count) - Timesheet integration (account.analytic.line extension) - Timesheet reports (by project, employee, task, week) - Task recurrence model - Task: planned/effective/remaining hours, progress, subtask hours - Project: allocated/remaining hours, profitability actions ORM Tests (102 tests, 0→1257 LOC): - domain_test.go: 32 tests (compile, operators, AND/OR/NOT, null) - field_test.go: 15 tests (IsCopyable, SQLType, IsRelational, IsStored) - model_test.go: 21 tests (NewModel, AddFields, RegisterMethod, ExtendModel) - domain_parse_test.go: 21 tests (parse Python domain strings) - sanitize_test.go: 13 tests (false→nil, type conversions) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
110 lines
2.6 KiB
Go
110 lines
2.6 KiB
Go
package orm
|
|
|
|
import "testing"
|
|
|
|
func TestSanitizeFieldValueBoolFalse(t *testing.T) {
|
|
// false for boolean field should stay false
|
|
f := &Field{Type: TypeBoolean}
|
|
got := sanitizeFieldValue(f, false)
|
|
if got != false {
|
|
t.Errorf("expected false, got %v", got)
|
|
}
|
|
}
|
|
|
|
func TestSanitizeFieldValueBoolTrue(t *testing.T) {
|
|
f := &Field{Type: TypeBoolean}
|
|
got := sanitizeFieldValue(f, true)
|
|
if got != true {
|
|
t.Errorf("expected true, got %v", got)
|
|
}
|
|
}
|
|
|
|
func TestSanitizeFieldValueCharFalse(t *testing.T) {
|
|
// false for char field should become nil
|
|
f := &Field{Type: TypeChar}
|
|
got := sanitizeFieldValue(f, false)
|
|
if got != nil {
|
|
t.Errorf("expected nil, got %v", got)
|
|
}
|
|
}
|
|
|
|
func TestSanitizeFieldValueIntFalse(t *testing.T) {
|
|
f := &Field{Type: TypeInteger}
|
|
got := sanitizeFieldValue(f, false)
|
|
if got != nil {
|
|
t.Errorf("expected nil, got %v", got)
|
|
}
|
|
}
|
|
|
|
func TestSanitizeFieldValueFloatFalse(t *testing.T) {
|
|
f := &Field{Type: TypeFloat}
|
|
got := sanitizeFieldValue(f, false)
|
|
if got != nil {
|
|
t.Errorf("expected nil, got %v", got)
|
|
}
|
|
}
|
|
|
|
func TestSanitizeFieldValueM2OFalse(t *testing.T) {
|
|
f := &Field{Type: TypeMany2one}
|
|
got := sanitizeFieldValue(f, false)
|
|
if got != nil {
|
|
t.Errorf("expected nil, got %v", got)
|
|
}
|
|
}
|
|
|
|
func TestSanitizeFieldValueDateFalse(t *testing.T) {
|
|
f := &Field{Type: TypeDate}
|
|
got := sanitizeFieldValue(f, false)
|
|
if got != nil {
|
|
t.Errorf("expected nil, got %v", got)
|
|
}
|
|
}
|
|
|
|
func TestSanitizeFieldValueFloat64ToInt(t *testing.T) {
|
|
f := &Field{Type: TypeInteger}
|
|
got := sanitizeFieldValue(f, float64(42))
|
|
if got != int64(42) {
|
|
t.Errorf("expected int64(42), got %T %v", got, got)
|
|
}
|
|
}
|
|
|
|
func TestSanitizeFieldValueM2OFloat(t *testing.T) {
|
|
f := &Field{Type: TypeMany2one}
|
|
got := sanitizeFieldValue(f, float64(5))
|
|
if got != int64(5) {
|
|
t.Errorf("expected int64(5), got %T %v", got, got)
|
|
}
|
|
}
|
|
|
|
func TestSanitizeFieldValueNil(t *testing.T) {
|
|
f := &Field{Type: TypeChar}
|
|
got := sanitizeFieldValue(f, nil)
|
|
if got != nil {
|
|
t.Errorf("expected nil, got %v", got)
|
|
}
|
|
}
|
|
|
|
func TestSanitizeFieldValuePassthrough(t *testing.T) {
|
|
f := &Field{Type: TypeChar}
|
|
got := sanitizeFieldValue(f, "hello")
|
|
if got != "hello" {
|
|
t.Errorf("expected hello, got %v", got)
|
|
}
|
|
}
|
|
|
|
func TestSanitizeFieldValueIntPassthrough(t *testing.T) {
|
|
f := &Field{Type: TypeInteger}
|
|
got := sanitizeFieldValue(f, int64(99))
|
|
if got != int64(99) {
|
|
t.Errorf("expected int64(99), got %T %v", got, got)
|
|
}
|
|
}
|
|
|
|
func TestSanitizeFieldValueFloatPassthrough(t *testing.T) {
|
|
f := &Field{Type: TypeFloat}
|
|
got := sanitizeFieldValue(f, float64(3.14))
|
|
if got != float64(3.14) {
|
|
t.Errorf("expected 3.14, got %v", got)
|
|
}
|
|
}
|