'Create a res.partner.bank and set it as value of the  field bank_account_id'

def set_bank_account(self, acc_number, bank_id=None):

    self.ensure_one()
    self.bank_account_id = self.env['res.partner.bank'].create({'acc_number': acc_number, 'bank_id': bank_id, 'company_id': self.company_id.id, 'currency_id': self.currency_id.id, 'partner_id': self.company_id.partner_id.id}).id
