class AccountInvoice(models.Model):
_inherit = "account.invoice"
refund_count = fields.Integer(compute='_refund_no', string='Refund')
@api.one
@api.depends('refund_count')
def _refund_no(self):
for all in self.env['account.invoice'].search([('refund_invoice_id','=',self.id)]):
self.refund_count=len(all)
@api.multi
def action_view_refund(self):
return {
'name': _('Refund Invoice'),
'view_mode': 'form',
'view_id': self.env.ref('account.invoice_form').id,
'res_model': 'account.invoice',
'context': "{'type':'out_refund'}",
'type': 'ir.actions.act_window',
'res_id': self.refund_invoice_id,
}
view----------
<record id="oodo_arm_attendance_view_refund_inv" model="ir.ui.view">
<field name="name">sale.order.form.inherit.refund</field>
<field name="model">account.invoice</field>
<field name="inherit_id" ref="account.invoice_form"/>
<field name="arch" type="xml">
<xpath expr="//field[@name='number']" position="after">
<div class="oe_right oe_button_box">
<button name="action_view_refund" type="object" class="oe_stat_button" icon="fa-pencil-square-o" attrs="{'invisible': [('refund_count', '=', 0)]}">
<field name="refund_count" widget="statinfo" string="Refund" />
</button>
</div>
</xpath>
</field>
</record>
when i try this iam getting error like.......
raise TypeError(repr(o) + " is not JSON serializable") TypeError: account.invoice() is not JSON serializable