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>
53 lines
1.5 KiB
Go
53 lines
1.5 KiB
Go
package models
|
|
|
|
import "odoo-go/pkg/orm"
|
|
|
|
func Init() {
|
|
initSaleOrder()
|
|
initSaleOrderLine()
|
|
initResPartnerSaleExtension()
|
|
initSaleMargin()
|
|
initSaleOrderTemplate()
|
|
initSaleOrderTemplateLine()
|
|
initSaleOrderTemplateOption()
|
|
initSaleReport()
|
|
initSaleOrderWarnMsg()
|
|
initSaleAdvancePaymentWizard()
|
|
initSaleOrderExtension()
|
|
initSaleOrderLineExtension()
|
|
initSaleOrderDiscount()
|
|
initResPartnerSaleExtension2()
|
|
}
|
|
|
|
// initResPartnerSaleExtension extends res.partner with sale-specific fields.
|
|
// Mirrors: odoo/addons/sale/models/res_partner.py
|
|
//
|
|
// class ResPartner(models.Model):
|
|
// _inherit = 'res.partner'
|
|
// sale_order_count = fields.Integer(compute='_compute_sale_order_count')
|
|
// sale_order_ids = fields.One2many('sale.order', 'partner_id', string='Sales Orders')
|
|
func initResPartnerSaleExtension() {
|
|
partner := orm.ExtendModel("res.partner")
|
|
partner.AddFields(
|
|
orm.One2many("sale_order_ids", "sale.order", "partner_id", orm.FieldOpts{
|
|
String: "Sales Orders",
|
|
}),
|
|
orm.Integer("sale_order_count", orm.FieldOpts{
|
|
String: "Sale Order Count",
|
|
Compute: "_compute_sale_order_count",
|
|
}),
|
|
)
|
|
partner.RegisterCompute("sale_order_count", func(rs *orm.Recordset) (orm.Values, error) {
|
|
env := rs.Env()
|
|
partnerID := rs.IDs()[0]
|
|
var count int
|
|
err := env.Tx().QueryRow(env.Ctx(),
|
|
`SELECT COUNT(*) FROM sale_order WHERE partner_id = $1`, partnerID,
|
|
).Scan(&count)
|
|
if err != nil {
|
|
count = 0
|
|
}
|
|
return orm.Values{"sale_order_count": count}, nil
|
|
})
|
|
}
|