I am on account_voucher module, on voucher_payment_receipt_view.xml , I customized the view by a custom module, as follows :
from openerp.osv import fields, orm, osv
class AccountVoucher(orm.Model):
def _get_selection(self, cr, uid, context):
active_id = context.get('active',[])
voucher_rec = self.browse(cr, uid, active_id)
partner = voucher_rec.partner_id.id
cr.execute("SELECT num_bl,num_bl FROM stock_picking WHERE state='done' and invoice_state='2binvoiced' and partner_id=%d"%(partner))
return cr.fetchall()
_inherit = 'account.voucher'
_name = 'account.voucher'
_columns = {
'bls_to_pay': fields.one2many('stock.picking.out','bl_id','BLS to pay', readonly = True),
'Numeros_bl': fields.selection(_get_selection, 'Numeros Bls', size=32),
}
The field that interests us in this question is 'Numeros_bl' , I made it a dynamic selection, but I want to filter on the partner_id just selected, i em unable to get this partner_id selected on the current active record.
I want to pass the partner_id into the function _get_selection for that I think there is two solutions ( wich I wish to be corrected if wrong ) :
Passing directly the partner_id on the context via XML.
Passing the id of the current recored via ids[0] or active_id and browse on the current record id, then get the field partner_id.
I used selection field ( not functionnal field ) it doesn't take ids as a parameter, and I tried to pass the partner_id by XML context like this : <field name="Numeros_bl" context="{'active': active_id}"/>
Nothing of these solutions is working.
The problem now is how to get the partner_id so as to use it on the where condition ? Should I use a functionnal field instead of dynamic selection ?