Skip to Content
Menu
This question has been flagged
1459 Views

The following query is not working  error come is 
print(group_test['margin_amount'])
KeyError: 'margin_amount'​

test_group = self.env['account.invoice'].read_group([
('date_invoice', '>=', wizard.start_date),
('date_invoice', '<=', wizard.end_date)
], ['date_invoice', 'margin_amount'], ['date_invoice:day'], lazy=True, limit=None)
for group_test in test_group:
print(group_test['margin_amount'])
I just chagge margin_amount into amount_total then query work fine
and type of margin_amount is string and amount_total type is int
I thought error come by data type. so how to change data type in odoo api query
following query working fine
test_group = self.env['account.invoice'].read_group([
('date_invoice', '>=', wizard.start_date),
('date_invoice', '<=', wizard.end_date)
], ['date_invoice', 'amount_total'], ['date_invoice:day'], lazy=True, limit=None)
for group_test in test_group:
print(group_test['amount_total'])


Avatar
Discard