Fix P0-P2 bugs: sale.order M2M, display_name, DefaultGet
P0: Fix sale.order creation (was completely broken) - Corrected M2M junction table name from sale_order_line_account_tax_rel to account_tax_sale_order_line_rel (ORM sorts alphabetically) - Added fallback in BeforeCreate if sequence generation fails P1: Add display_name as magic field on ALL models - Added to addMagicFields() in pkg/orm/model.go (like Python BaseModel) - Computed on-the-fly in Read() from recName field, no DB column - Removed explicit display_name from res.partner (now auto-inherited) P2: Add DefaultGet hooks for sale.order and purchase.order - Sets company_id, currency_id, date_order/date_planned from environment - Follows same pattern as account.move's DefaultGet Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -129,6 +129,13 @@ func (m *Model) addMagicFields() {
|
||||
Readonly: true,
|
||||
}))
|
||||
|
||||
// display_name: computed on-the-fly from rec_name, not stored in DB.
|
||||
// Mirrors: odoo/orm/models.py BaseModel.display_name (computed field on ALL models)
|
||||
m.AddField(Char("display_name", FieldOpts{
|
||||
String: "Display Name",
|
||||
Compute: "_compute_display_name",
|
||||
}))
|
||||
|
||||
if m.logAccess {
|
||||
m.AddField(Many2one("create_uid", "res.users", FieldOpts{
|
||||
String: "Created by",
|
||||
|
||||
Reference in New Issue
Block a user