I have a one2many field on account_voucher, so as to display the deliveries uninvoiced of the selected partner.
For that I overrided the basic_onchange_partner methode of account_voucher, wich displayed tha default accout id of the selected partner, as follow :
from openerp.osv import fields, orm
class AccountVoucher(orm.Model):
_inherit = 'account.voucher'
_name = 'account.voucher'
_columns = {
'bls_to_pay': fields.one2many('stock.picking.out','bl_id','BLS to pay'),
}
def basic_onchange_partner(self, cr, uid, ids, partner_id, journal_id, ttype, context=None):
if context==None:
context={ }
super(AccountVoucher, self).basic_onchange_partner(cr,uid,ids, partner_id, journal_id, ttype, context)
DO = self.pool.get('stock.picking.out')
default = {
'value': {'bls_to_pay' : [] ,},
}
do2pay_ids = DO.search(cr, uid, [('partner_id','=',partner_id),('state','=','done'),('invoice_state','=','2binvoiced')])
for do2pay in do2pay_ids :
do_rec= DO.browse(cr, uid, do2pay)
rs = {
'num_bl': do_rec.num_bl,
'date' : do_rec.date,
'origin': do_rec.origin,
}
default['value']['bls_to_pay'].append(rs)
return default
When selecting the partner, an error occurs ( Client side ) saying : Uncaught Error: Champ state inconnu dans le domaine [["state","in",["cancel","done"]]]
and giving the following location : /web/static/src/js/view_form.js:1675
Why this error rises ?
I'll translate "Champ state inconnu dans le domaine " : " field state unknown on domain"
Yes Ivan, I used the field state on my onchange method, without putting it on the xml view.