Add stored form views, SO line compute, invoice line demo data
- Stored form views for CRM lead, purchase order, HR employee, project - SO line price_subtotal compute (qty * price * (1 - discount/100)) - Invoice lines seeded for demo invoices (product + tax + receivable) - O2M lines now visible in form views (sale orders + invoices) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -605,6 +605,26 @@ func initSaleOrderLine() {
|
||||
orm.Integer("sequence", orm.FieldOpts{String: "Sequence", Default: 10}),
|
||||
)
|
||||
|
||||
// -- Computed: _compute_amount (line subtotal/total) --
|
||||
// Computes price_subtotal and price_total from qty, price, discount.
|
||||
// Mirrors: odoo/addons/sale/models/sale_order_line.py SaleOrderLine._compute_amount()
|
||||
computeLineAmount := func(rs *orm.Recordset) (orm.Values, error) {
|
||||
env := rs.Env()
|
||||
lineID := rs.IDs()[0]
|
||||
var qty, price, discount float64
|
||||
env.Tx().QueryRow(env.Ctx(),
|
||||
`SELECT COALESCE(product_uom_qty, 0), COALESCE(price_unit, 0), COALESCE(discount, 0)
|
||||
FROM sale_order_line WHERE id = $1`, lineID,
|
||||
).Scan(&qty, &price, &discount)
|
||||
subtotal := qty * price * (1 - discount/100)
|
||||
return orm.Values{
|
||||
"price_subtotal": subtotal,
|
||||
"price_total": subtotal, // TODO: add tax amount for price_total
|
||||
}, nil
|
||||
}
|
||||
m.RegisterCompute("price_subtotal", computeLineAmount)
|
||||
m.RegisterCompute("price_total", computeLineAmount)
|
||||
|
||||
// -- Delivery & Invoicing Quantities --
|
||||
m.AddFields(
|
||||
orm.Float("qty_delivered", orm.FieldOpts{String: "Delivered Quantity"}),
|
||||
|
||||
Reference in New Issue
Block a user