Massive module expansion: Stock, CRM, HR — +2895 LOC

Stock (1193→2867 LOC):
- Valuation layers (FIFO consumption, product valuation history)
- Landed costs (split by equal/qty/cost/weight/volume, validation)
- Stock reports (by product, by location, move history, valuation)
- Forecasting (on_hand + incoming - outgoing per product)
- Batch transfers (confirm/assign/done with picking delegation)
- Barcode interface (scan product/lot/package/location, qty increment)

CRM (233→1113 LOC):
- Sales teams with dashboard KPIs (opportunity count/amount/unassigned)
- Team members with lead capacity + round-robin auto-assignment
- Lead extended: activities, UTM tracking, scoring, address fields
- Lead methods: merge, duplicate, schedule activity, set priority/stage
- Pipeline analysis (stages, win rate, conversion, team/salesperson perf)
- Partner onchange (auto-populate contact from partner)

HR (223→520 LOC):
- Leave management: hr.leave.type, hr.leave, hr.leave.allocation
  with full approval workflow (draft→confirm→validate/refuse)
- Attendance: check in/out with computed worked_hours
- Expenses: hr.expense + hr.expense.sheet with state machine
- Skills/Resume: skill types, employee skills, resume lines
- Employee extensions: skills, attendance, leave count links

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Marc
2026-04-03 23:21:52 +02:00
parent 0a76a2b9aa
commit bdb97f98ad
16 changed files with 2895 additions and 0 deletions

View File

@@ -0,0 +1,30 @@
package models
import "odoo-go/pkg/orm"
// initHrAttendance registers the hr.attendance model.
// Mirrors: odoo/addons/hr_attendance/models/hr_attendance.py
func initHrAttendance() {
m := orm.NewModel("hr.attendance", orm.ModelOpts{
Description: "Attendance",
Order: "check_in desc",
})
m.AddFields(
orm.Many2one("employee_id", "hr.employee", orm.FieldOpts{String: "Employee", Required: true}),
orm.Datetime("check_in", orm.FieldOpts{String: "Check In", Required: true}),
orm.Datetime("check_out", orm.FieldOpts{String: "Check Out"}),
orm.Float("worked_hours", orm.FieldOpts{String: "Worked Hours", Compute: "_compute_worked_hours", Store: true}),
orm.Many2one("company_id", "res.company", orm.FieldOpts{String: "Company"}),
)
m.RegisterCompute("worked_hours", func(rs *orm.Recordset) (orm.Values, error) {
env := rs.Env()
attID := rs.IDs()[0]
var hours float64
env.Tx().QueryRow(env.Ctx(),
`SELECT COALESCE(EXTRACT(EPOCH FROM (check_out - check_in)) / 3600.0, 0)
FROM hr_attendance WHERE id = $1 AND check_out IS NOT NULL`, attID,
).Scan(&hours)
return orm.Values{"worked_hours": hours}, nil
})
}