Přejít na obsah
Menu
You need to be registered to interact with the community.
This question has been flagged
3 Odpovědi
3096 Zobrazení

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 ?

Avatar
Zrušit
Autor

I'll translate "Champ state inconnu dans le domaine " : " field state unknown on domain"

Autor

Yes Ivan, I used the field state on my onchange method, without putting it on the xml view.

Nejlepší odpověď

It is usually happen when you use the field that is not included in view. All fields to be included in view or to be passed to on_change need to be included in view although they can be invisible.

Avatar
Zrušit
Nejlepší odpověď

Error occurs when state field is not used in the view [tree/form]... but you would have added states property either in your Python code or Xml code... Hence that error is occured..

So do add the field "state" in the views... if it is of no use to you then add "invisible" property to it


 

Avatar
Zrušit
Nejlepší odpověď

I think the error is on your view xml, can you put the code of your view file?

Avatar
Zrušit