Skip to Content
Menu
This question has been flagged
3947 Views

Hi,

How to display an account bank number(acc number) in the form of payment using the field partner_id?

----------------------------------------------

python  code:

class account_payment(models.Model):   

 _inherit = "account.payment"   

 _description = "Payments"

partner_id   = fields.Many2one('res.partner')

bank_account_id = fields.Many2one(compute='_compute_bank_account', string='Bank Account',readonly=True)

@api.multi
def _compute_bank_account(self):

     if self.partner_id:                

            self.env.cr.execute('select acc_number from res_partner_bank where partner_id = %s ', (self.partner_id.id))


 I want the account number displayed as soon as the partner_id is selected.

 I don't get the output I want from the above code  .

 please guide me  .

Thanks.

Avatar
Discard

Hi,

Currently the partner bank account is a One2many field in the partner form, it can accept multiple values.Either you can change the bank account field in the payment form to the Many2many or One2many, another option is if there are multiple bank accounts limit search result to one and can write into the Many2one field.Instead of compute method you can use onchange of partner_id