This question has been flagged
2169 Views

Hi everyone,

Please in the customer/supplier refund I need to get the invoice_line depending to the invoice_id of selected partner for that I had used this one below so any suggestion for how can I get invoice_line (I have used onchange on invoice_id but when I edit invoice line or when I save lines disapper)

'invoice_id' : fields.many2one('account.invoice', string='Invoice number'),
  def fields_view_get(self, cr, uid, view_id=None, view_type='form', context=None, toolbar=False, submenu=False):
        """
        """
 
        res = super(kms_invoice, self).fields_view_get(cr, uid, view_id=view_id, view_type=view_type, context=context,
                                                        toolbar=toolbar, submenu=submenu)
        invoice_type = context.get('default_type')
        type = context.get('type')
        invoice_obj = self.pool.get('account.invoice')
        inv =invoice_obj.browse(cr, uid, context=context)
        if invoice_type == 'out_refund' or type == 'in_refund':
            doc = etree.XML(res['arch'])
            for node in doc.xpath("//field[@name='invoice_id']"):
                node.set('domain', "[('partner_id', '=', partner_id),('state','!=','draft'),('type','not in',('out_refund','in_refund'))]")
                setup_modifiers(node, res['fields']['invoice_id'])
            res['arch'] = etree.tostring(doc)
        return res 
Avatar
Discard