odoo在底部顯示制定欄位合計and彙總時顯示合計
阿新 • • 發佈:2019-02-15
- odoo的tree檢視底部顯示合計
取自sale.view_order_tree 銷售訂單 tree 檢視
<field name="amount_total" sum="Total Tax Included"/>
- odoo使用group by分組時顯示欄位合計
read_group
method
of the class:class your_class(osv.osv): # ... def read_group(self, cr, uid, domain, fields, groupby, offset=0, limit=None, context=None, orderby=False, lazy=True): res = super(your_class, self).read_group(cr, uid, domain, fields, groupby, offset, limit=limit, context=context, orderby=orderby, lazy=lazy) if 'amount_pending' in fields: for line in res: if '__domain' in line: lines = self.search(cr, uid, line['__domain'], context=context) pending_value = 0.0 for current_account in self.browse(cr, uid, lines, context=context): pending_value += current_account.amount_pending line['amount_pending'] = pending_value if 'amount_payed' in fields: for line in res: if '__domain' in line: lines = self.search(cr, uid, line['__domain'], context=context) payed_value = 0.0 for current_account in self.browse(cr, uid, lines, context=context): payed_value += current_account.amount_payed line['amount_payed'] = payed_value return res
If you want, for example, remove the sum of a column in the group by, you can do something like this:
class your_class(osv.osv): # ... def read_group(self, cr, uid, domain, fields, groupby, offset=0, limit=None, context=None, orderby=False, lazy=True): if 'column' in fields: fields.remove('column') return super(your_class, self).read_group(cr, uid, domain, fields, groupby, offset, limit=limit, context=context, orderby=orderby, lazy=lazy):