diff --git a/addons/sale/models/sale_order.go b/addons/sale/models/sale_order.go
index 181425b..adbf1b6 100644
--- a/addons/sale/models/sale_order.go
+++ b/addons/sale/models/sale_order.go
@@ -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"}),
diff --git a/pkg/server/web_methods.go b/pkg/server/web_methods.go
index 33d2d0f..2e1dc5a 100644
--- a/pkg/server/web_methods.go
+++ b/pkg/server/web_methods.go
@@ -442,12 +442,12 @@ func (s *Server) handleReadGroup(rs *orm.Recordset, params CallKWParams) (interf
// web_read_group: also get total group count (without limit/offset)
totalLen := len(results)
if opts.Limit > 0 || opts.Offset > 0 {
- // Re-query without limit/offset to get total
allResults, err := rs.ReadGroup(domain, groupby, []string{"__count"})
if err == nil {
totalLen = len(allResults)
}
}
+
return map[string]interface{}{
"groups": groups,
"length": totalLen,
diff --git a/pkg/service/db.go b/pkg/service/db.go
index 633d624..c785b4b 100644
--- a/pkg/service/db.go
+++ b/pkg/service/db.go
@@ -687,7 +687,136 @@ func seedViews(ctx context.Context, tx pgx.Tx) {